-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnnCommand.coffee
64 lines (53 loc) · 1.93 KB
/
nnCommand.coffee
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
{
log, withoutTrailingSlash, promiseSequence, compactFlatten
} = require "./source/NeptuneNamespaces/MiniFoundation"
Generator = require "./source/NeptuneNamespaces/Generator"
{version} = require './package.json'
standardRoots = for root in Generator.standardRoots
"#{root}/*"
Commander = require "commander"
.version version
.usage '[options] <root ...>'
.option '-r, --root', 'list one or more --root arguments'
.option '-w, --watch', 'stay running, watch for changes, and automatically update'
.option '-v, --verbose', 'enable verbose output'
.option '-q, --quiet', 'suppress all output'
.option '-j, --js', 'output .js files instead of .coffee (experimental)'
.option '--cleanup', 'cleanup .coffee files if generating .js or visa-versa'
.option '-f, --force', 'overwrite all index and namespace files'
.option '-s, --std', "include the standard roots: #{standardRoots.join ', '}"
.on "--help", ->
console.log "
Generates 'namespace.(js|coffee)' and 'index.(js|coffee)' files to bind each specified root
to the global Neptune namespace at runtime.
\n\nRun with -v to see everything NN is doing.
"
.parse process.argv
run = (targetPaths, {watch, verbose, quiet, force, js, cleanup}) ->
if verbose
console.log """
neptune-namespaces (#{version})
roots: #{targetPaths.join ', '}
"""
log {watch, verbose, quiet, force, js, cleanup}
todoList = for targetPath in targetPaths
do (targetPath) ->
targetPath = withoutTrailingSlash targetPath
doWork = ->
Generator.generate targetPath, {
verbose
force
quiet
watch
cleanup
js
persistent: true
}
doWork
promiseSequence todoList
root = Commander.args || []
root = root.concat standardRoots if Commander.std
if root.length == 0
console.error "no roots specified (run with -h for help)"
else
run root, Commander