-
Notifications
You must be signed in to change notification settings - Fork 12
/
index.js
executable file
·69 lines (57 loc) · 1.61 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
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
#!/usr/bin/env node
'use strict'
var args = process.argv.slice(2)
var argv = require('minimist')(args)
var install = false
if (args.length) {
var arg = args[0].toLowerCase()
if (arg === 'install' || arg === 'i') install = true
}
if (install) {
const mock = require('mock-require')
if (!process.env.NPM_GIF_FRAME_THROTTLE) process.env.NPM_GIF_FRAME_THROTTLE = '500ms'
mock('gauge', require('./gauge-gif'))
const npm = require('global-npm')
var globalInstall = false
var noSave = false
var save = false
var saveBundle = false
var saveDev = false
var saveExact = false
var saveOpt = false
var saveProd = false
if (argv['global'] || argv['g']) globalInstall = true
if (argv['no-save']) noSave = true
if (argv['save'] || argv['S']) save = true
if (argv['save-bundle'] || argv['B']) saveBundle = true
if (argv['save-dev'] || argv['D']) saveDev = true
if (argv['save-exact'] || argv['E']) saveExact = true
if (argv['save-optional'] || argv['O']) saveOpt = true
if (argv['save-production'] || argv['P']) saveOpt = true
argv._.shift()
npm.load({
'loglevel': 'silent',
'global': globalInstall,
'no-save': noSave,
'save': save,
'save-bundle': saveBundle,
'save-dev': saveDev,
'save-exact': saveExact,
'save-optional': saveOpt,
'save-production': saveProd
}, err => {
if (err) {
console.error(err)
} else {
npm.commands.install(argv._, (err, data) => {
if (err) console.error(err)
})
}
})
} else {
const spawn = require('cross-spawn-async')
spawn('npm', args, {
cwd: process.cwd(),
stdio: 'inherit'
})
}