Skip to content

Commit

Permalink
Fix linter error
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankristianto committed Feb 13, 2022
1 parent 2007be2 commit b12f61f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 44 deletions.
13 changes: 3 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@10up/eslint-config": "^2.2.0",
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.10",
"@babel/eslint-parser": "^7.17.0",
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@babel/register": "^7.12.10",
Expand Down
3 changes: 2 additions & 1 deletion src/classes/cloudflare.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class Cloudflare extends Request {
*/
static isDomain(str) {
try {
const regex = /(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/s;
const regex =
/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/s;
if (regex.exec(str) !== null) {
const urlTest = str.includes('http') ? str : `https://${str}`;
const urlObj = new URL(urlTest);
Expand Down
68 changes: 35 additions & 33 deletions src/utils/withSpinner.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,42 @@

import ora from 'ora';
// Spinner
const withSpinner = (command) => (...args) => {
const { disableSpinner } = args[0];
const withSpinner =
(command) =>
(...args) => {
const { disableSpinner } = args[0];

if (disableSpinner) {
// eslint-disable-next-line no-param-reassign
args[0].spinner = {};
return command(...args);
}
if (disableSpinner) {
// eslint-disable-next-line no-param-reassign
args[0].spinner = {};
return command(...args);
}

const spinner = ora().start();
// eslint-disable-next-line no-param-reassign
args[0].spinner = spinner;
let time = process.hrtime();
return command(...args).then(
(message) => {
time = process.hrtime(time);
spinner.succeed(
`${message || spinner.text} (in ${time[0]}s ${(time[1] / 1e6).toFixed(0)}ms)`,
);
process.exit(0);
},
(error) => {
if (error) {
// Error is an unknown error. That means there was a bug in our code.
spinner.fail(typeof error === 'string' ? error : error.message);
// Disable reason: Using console.error() means we get a stack trace.
console.error(error);
process.exit(1);
} else {
spinner.fail('An unknown error occurred.');
process.exit(1);
}
},
);
};
const spinner = ora().start();
// eslint-disable-next-line no-param-reassign
args[0].spinner = spinner;
let time = process.hrtime();
return command(...args).then(
(message) => {
time = process.hrtime(time);
spinner.succeed(
`${message || spinner.text} (in ${time[0]}s ${(time[1] / 1e6).toFixed(0)}ms)`,
);
process.exit(0);
},
(error) => {
if (error) {
// Error is an unknown error. That means there was a bug in our code.
spinner.fail(typeof error === 'string' ? error : error.message);
// Disable reason: Using console.error() means we get a stack trace.
console.error(error);
process.exit(1);
} else {
spinner.fail('An unknown error occurred.');
process.exit(1);
}
},
);
};

export default withSpinner;

0 comments on commit b12f61f

Please sign in to comment.