|
@@ -1,29 +1,36 @@
|
|
|
const fs = require('fs-extra');
|
|
|
const path = require('path');
|
|
|
const jsonfile = require('jsonfile');
|
|
|
-const argv = require('yargs')
|
|
|
- .usage('Usage: $0 -d <dist>')
|
|
|
- .option('s', {
|
|
|
- alias: 'source',
|
|
|
+const yargs = require('yargs')(process.argv.slice(2));
|
|
|
+const argv = yargs
|
|
|
+ .usage('Usage: $0 -s <source> -d <dist>')
|
|
|
+ .help('help')
|
|
|
+ .alias('version', 'v')
|
|
|
+ .option('help', {
|
|
|
+ alias: 'h'
|
|
|
+ })
|
|
|
+ .option('source', {
|
|
|
+ alias: 's',
|
|
|
type: 'string',
|
|
|
+ requiresArg: true,
|
|
|
describe: 'The directory where dependencies is.',
|
|
|
})
|
|
|
- .option('d', {
|
|
|
- alias: 'dist',
|
|
|
+ .option('dist', {
|
|
|
+ alias: 'd',
|
|
|
type: 'string',
|
|
|
+ requiresArg: true,
|
|
|
describe: 'The directory where dependencies would be copies to.',
|
|
|
})
|
|
|
- .option('r', {
|
|
|
- alias: 'dryrun',
|
|
|
+ .option('dryrun', {
|
|
|
type: 'boolean',
|
|
|
describe: 'Find the dependencies and log to the screen only.',
|
|
|
})
|
|
|
- .option('v', {
|
|
|
- alias: 'verbose',
|
|
|
+ .option('verbose', {
|
|
|
+ alias: 'V',
|
|
|
type: 'boolean',
|
|
|
describe: 'Enable verbose log.',
|
|
|
})
|
|
|
- .parse();
|
|
|
+ .argv;
|
|
|
|
|
|
const pkgfile = require('./package');
|
|
|
|
|
@@ -104,8 +111,12 @@ function copyDependencies(dependenciesDir, dist) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-let dependencies = getDependencies([], 0, argv.source, pkgfile.mainDependencies);
|
|
|
+if (!argv.source || !argv.dist || argv.help) {
|
|
|
+ yargs.showHelp();
|
|
|
+} else {
|
|
|
+ let dependencies = getDependencies([], 0, argv.source, pkgfile.mainDependencies);
|
|
|
|
|
|
-if (!argv.dryrun) {
|
|
|
- copyDependencies(dependencies, argv.dist);
|
|
|
+ if (!argv.dryrun) {
|
|
|
+ copyDependencies(dependencies, argv.dist);
|
|
|
+ }
|
|
|
}
|