-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·40 lines (37 loc) · 1.23 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /usr/bin/env node
const yargs = require('yargs/yargs');
const path = require('path');
const prompts = require('prompts');
const child_process = require('child_process');
yargs(process.argv.slice(2))
.command(
'init [dirname]',
'create a new project',
yargs => yargs.positional('dirname', {
describe: 'the directory of the new project',
default: 'project-template'
}),
async argv => {
child_process.execSync('git clone https://github.com/Lohoyo/project-template.git ' + argv.dirname);
let install;
if (argv.install === undefined) {
const response = await prompts({
type: 'confirm',
name: 'value',
message: 'Would you like to install npm dependencies now?',
initial: true
});
install = response.value;
} else {
install = argv.install;
}
if (install) {
child_process.execSync('npm i', {cwd: argv.dirname});
}
}
)
.option('install', {
type: 'boolean',
description: 'Install npm dependencies'
})
.argv;