/
install.js
executable file
·35 lines (27 loc) · 1.13 KB
/
install.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
var ARGS_PARSER = require("sourcemint-util-js/lib/args").Parser;
var CLI = require("../cli");
var PM = require("sourcemint-pm-sm/lib/pm");
var command = exports["install"] = new ARGS_PARSER();
command.help("Install package/program.");
command.arg(".../[package.json|program.json]").optional();
command.option("--dev").bool().help("Install dev dependencies as well.");
// NOTE: We don't default to 'now' on install as we want to be able to install 100% from cache in case network is down.
command.option("-n", "--now").bool().help("Aggressively fetch latest remote info (equivalent to `sm update`).");
command.option("-N", "--no-native-install").bool().help("Don't call native package installer (if applicable).");
command.helpful();
command.action(function (options) {
var basePath = CLI.checkPackageProgramPathInArguments(options.args);
if (!basePath) {
return;
}
if (options.now) {
options.update = true;
}
PM.forProgramPath(basePath).then(function(pm) {
return pm.install(options);
}).then(function() {
process.exit(0);
}).fail(function(err) {
CLI.failAndExit(err);
});
});