This repository has been archived by the owner on Aug 15, 2018. It is now read-only.
/
spm-install
executable file
·50 lines (44 loc) · 1.63 KB
/
spm-install
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
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
require('colorful').colorful();
var commander = require('commander');
var install = require('../lib/client').install;
var log = require('../lib/utils/log');
commander
.usage('[options] name[@version]')
.option('--registry <url>', 'registry url of yuan server')
.option('-I, --input-directory <dir>', 'input directory, default: current working directory')
.option('-d, --destination <dir>', 'output directory, default: sea-modules')
.option('-f, --force', 'force to download a unstable module')
.option('-q, --quiet', 'show less logs')
.option('-S, --save', 'save alias to package.json')
.option('-SD, --save-dev', 'save devAlias to package.json')
.option('--verbose', 'show more logs')
.option('--no-color', 'disable colorful print');
commander.on('--help', function() {
console.log();
console.log(' ' + 'Examples:'.to.bold.blue);
console.log();
console.log(' $ ' + 'spm install'.to.magenta.color + ' jquery');
console.log(' $ ' + 'spm install'.to.magenta.color + ' jquery arale-class');
console.log(' $ ' + 'spm install'.to.magenta.color + ' jquery' +
'@1.8.2'.to.cyan.color);
console.log(' $ ' + 'spm install'.to.magenta.color + ' underscore --save');
console.log();
});
commander.parse(process.argv);
console.log();
log.config(commander);
install({
registry: commander.registry,
cwd: commander.inputDirectory,
destination: commander.destination,
force: commander.force,
save: commander.save,
saveDev: commander.saveDev,
name: commander.args.length ? commander.args : null
}, function(err) {
if (err) {
log.error('exit', err.message);
process.exit(2);
}
});