UNPKG

2.23 kBtext/coffeescriptView Raw
1
2exec = require('child_process').exec
3
4program = require 'commander'
5
6aspm = require '../lib'
7
8pkg = require '../package.json'
9
10fail = (err) ->
11 console.error err.message
12 console.error "not ok".red
13 process.exit 1
14 return
15
16program
17.version "v#{pkg.version}"
18.description 'Install and build npm modules for Atom-Shell'
19.option '-t, --target <version>', 'Atom-Shell version'
20.option '-a, --arch <arch>', 'target architecture'
21.option '-p, --target-platform <platform>', 'target platform'
22.option '-s, --save', 'save as dependency to package.json'
23.option '-s, --save-dev', 'save as devDependency to package.json'
24.option '-g', 'install globally with normal npm'
25.option '--tarball [url/path]', 'install from [remote] tarball'
26.option '--quiet', "don't say anything"
27.option '--run-scripts', "do not use --ignore-scripts flag"
28.option '--compatibility', "try for max compability"
29
30program
31.command 'install [module]'
32.alias 'i'
33.description 'install module (fetch & build)'
34.action (module) ->
35 if program.G
36 # with -g flag we use npm directly
37 cmd = "npm #{process.argv.slice(2).join(' ')}"
38 aspm.runCmd cmd, {}, no, (err) -> fail err if err; console.log "ok".green
39 else
40 aspm.installModule module, program, (err) -> fail err if err; console.log "ok".green
41
42program
43.command 'fetch [module]'
44.alias 'f'
45.description 'fetch module'
46.action (module) ->
47 aspm.fetchModule module, program, (err) -> fail err if err; console.log "ok".green
48
49program
50.command 'build <module>'
51.alias 'b'
52.description 'build module'
53.action (module) ->
54 aspm.buildModule module, program, (err) -> fail err if err; console.log "ok".green
55
56
57# pass-through some npm commands directly
58# we only do build, install, rebuild, update
59if process.argv[2] in 'adduser bin bugs bundle cache completion config dedupe deprecate docs edit explore help help-search init info link ls npm outdated owner pack prefix prune publish repo restart rm root run run-script search shrinkwrap star stars start stop tag test uninstall unpublish version view whoami'.split ' '
60 cmd = "npm #{process.argv.slice(2).join(' ')}"
61 aspm.runCmd cmd, {}, no, (err) -> fail err if err; console.log "ok".green
62else
63 program.parse process.argv
64 program.help() if program.args.length is 0
65
66