Skip to content

Commit 416cb60

Browse files
committed
refactor: prettier
1 parent c771118 commit 416cb60

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

cli.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
#!/usr/bin/env node
2-
'use strict'
3-
const yargs_parser = require('yargs-parser')
4-
const path = require("path");
2+
'use strict';
3+
const yargs_parser = require('yargs-parser');
4+
const path = require('path');
55
const chalk = require('chalk');
6-
const ora = require("ora");
6+
const ora = require('ora');
77
const { extract } = require('pacote');
8-
const fs = require("fs-extra");
8+
const fs = require('fs-extra');
99
const os = require('os');
1010
const packageName = 'html5-boilerplate';
11-
const tempDir = os.tmpdir()+`/${packageName}-staging`;
12-
const elapsed = require("elapsed-time-logger");
11+
const tempDir = os.tmpdir() + `/${packageName}-staging`;
12+
const elapsed = require('elapsed-time-logger');
1313

1414
module.exports = async () => {
15-
const argv = yargs_parser(process.argv.slice(2), {alias:{release: ['r']}});
16-
const timer = elapsed.start();
17-
const version = argv['release'] || 'latest';
18-
const targetDir = path.resolve(argv['_'][0] || './');
19-
const spinner = ora(`Downloading ${packageName} version '${version}' to ${targetDir}`).start();
20-
await fs.ensureDir(tempDir);
21-
try{
22-
const { from: nameWithVersion } = await extract(packageName + '@' + version, tempDir, {});
23-
spinner.text = `${nameWithVersion} copied to ${targetDir} in ${timer.get()}. Have fun!`;
24-
}catch(err){
25-
await fs.remove(tempDir);
26-
if(err.code === 'ETARGET'){
27-
spinner.fail(chalk.red(`version '${err.wanted}' not found in npm registry\navailable versions:`));
28-
console.log(err.versions.reverse().join(' | '));
29-
process.exit(1);
30-
}/* istanbul ignore next */else{
31-
spinner.fail('Unexpected error');
32-
console.error(err);
33-
process.exit(-1);
34-
};
35-
return;
36-
}
37-
await fs.copy(tempDir+'/dist', targetDir);
38-
await fs.remove(tempDir);
39-
spinner.succeed();
40-
return;
41-
};
15+
const argv = yargs_parser(process.argv.slice(2), { alias: { release: ['r'] } });
16+
const timer = elapsed.start();
17+
const version = argv['release'] || 'latest';
18+
const targetDir = path.resolve(argv['_'][0] || './');
19+
const spinner = ora(`Downloading ${packageName} version '${version}' to ${targetDir}`).start();
20+
await fs.ensureDir(tempDir);
21+
try {
22+
const { from: nameWithVersion } = await extract(packageName + '@' + version, tempDir, {});
23+
spinner.text = `${nameWithVersion} copied to ${targetDir} in ${timer.get()}. Have fun!`;
24+
} catch (err) {
25+
await fs.remove(tempDir);
26+
if (err.code === 'ETARGET') {
27+
spinner.fail(chalk.red(`version '${err.wanted}' not found in npm registry\navailable versions:`));
28+
console.log(err.versions.reverse().join(' | '));
29+
process.exit(1);
30+
} /* istanbul ignore next */ else {
31+
spinner.fail('Unexpected error');
32+
console.error(err);
33+
process.exit(-1);
34+
}
35+
return;
36+
}
37+
await fs.copy(tempDir + '/dist', targetDir);
38+
await fs.remove(tempDir);
39+
spinner.succeed();
40+
return;
41+
};

0 commit comments

Comments
 (0)