/
cnpm
executable file
·92 lines (79 loc) · 2.74 KB
/
cnpm
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env node
/**!
* cnpm - bin/cnpm
*
* Copyright(c) cnpmjs.org and other contributors.
* MIT Licensed
*
* Authors:
* fengmk2 <fengmk2@gmail.com> (http://fengmk2.github.com)
*/
'use strict';
/**
* Module dependencies.
*/
var program = require('commander');
var child_process = require('child_process');
var pkg = require('../package.json');
var config = require('../config');
var help = {
'help': 1,
'-h': 1,
'--help': 1,
'usage': 1
};
var action = process.argv[2];
if (!action || help[action]) {
var helpInfo = 'Usage: cnpm <command>\n' +
'Help: http://cnpmjs.org/help/cnpm\n\n' +
' Extend command\n' +
' web open cnpm web (ex.: tnpm web)\n' +
' check [ingoreupdate] check project dependencies, add ignoreupdate will not check modules\' latest version(ex.: cnpm check, cnpm check -i)\n' +
' doc [moduleName] open document page (ex.: cnpm doc urllib)\n' +
' sync [moduleName] sync module from source npm (ex.: cnpm sync urllib)\n' +
'\n' +
' npm command use --registry=' + config.cnpmRegistry + '\n' +
' where <command> is one of:\n' +
' add-user, adduser, apihelp, author, bin, bugs, c, cache,\n' +
' completion, config, ddp, dedupe, deprecate, docs, edit,\n' +
' explore, faq, find, find-dupes, get, help, help-search,\n' +
' home, i, info, init, install, isntall, la, link, list, ll,\n' +
' ln, login, ls, outdated, owner, pack, prefix, prune,\n' +
' publish, r, rb, rebuild, remove, restart, rm, root,\n' +
' run-script, s, se, search, set, show, shrinkwrap, star,\n' +
' start, stop, submodule, tag, test, tst, un, uninstall,\n' +
' unlink, unpublish, unstar, up, update, version, view,\n' +
' whoami\n' +
' npm <cmd> -h quick help on <cmd>\n' +
' npm -l display full usage info\n' +
' npm faq commonly asked questions\n' +
' npm help <term> search for help on <term>\n' +
' npm help npm involved overview\n\n' +
' Specify configs in the ini-formatted file:\n' +
' ' + config.customConfig + '\n' +
' or on the command line via: npm <command> --key value\n' +
' Config info can be viewed via: npm help config';
console.log(helpInfo);
process.exit(0);
}
if (action === '-v' || action === '--version') {
console.log(pkg.version);
process.exit(0);
}
var extendsMethd = {
web: 1,
check: 1,
doc: 1,
sync: 1,
};
if (extendsMethd[action]) {
program
.command('web', 'open cnpm web')
.command('check', 'check the dependencies in project')
.command('doc [modulename]', 'open document page')
.command('sync [moduleName]', 'sync module from source npm')
.parse(process.argv);
return;
}
//origin npm with taobao registry
require('../origin_npm.js');