1 | program = require 'commander'
|
2 | logging = require './logging'
|
3 | fs = require 'fs'
|
4 | _ = require 'underscore'
|
5 |
|
6 | module.exports = ->
|
7 | Package = require './package'
|
8 | program.name = 'jspackle'
|
9 |
|
10 | version = JSON.parse(fs.readFileSync(__dirname+'/../package.json')).version
|
11 |
|
12 | console.log "jspackle v#{version}\n"
|
13 |
|
14 | task = ->
|
15 | console.log """No valid command provided!:
|
16 | jspackle (build|test)
|
17 | """
|
18 |
|
19 | opts = {}
|
20 | program
|
21 | .version(version)
|
22 | .option('-v, --verbose', 'Include debugging information in the output')
|
23 | .option('-q, --quiet', 'Only print critical errors to the screen')
|
24 | .option('-n, --no-color', 'Disable colors in the output')
|
25 | .option('-m, --minify', 'Minify the build (uses uglify-js)')
|
26 | .option('-c, --coffee', 'Look for and compile coffee-script files')
|
27 | .option('-r, --root <root>', 'The of the project', process.cwd()+'/')
|
28 | .option('-p, --path <path>', 'Path of the config file, relative to root', 'jspackle.json')
|
29 | .option('-s, --test_server <test_server>', 'Test server', 'http://localhost:9876')
|
30 | .option('-t, --test_timeout <test_timeout>', 'Test timeout (in seconds)', 90)
|
31 | .option('-a, --test_args <test_args>', 'Additional args to pass to the underlying tester', '')
|
32 | .option('-o, --build_output <build_output>', 'File to write built project')
|
33 | .option('-d, --include_depends', 'Should the dependencies be included in the build?')
|
34 |
|
35 | test = program
|
36 | .command('test')
|
37 | .description(' - Execute tests')
|
38 | .action (env)->
|
39 | task = ->
|
40 | logging.info "Executing command: 'test'"
|
41 | p = new Package opts
|
42 | p.test()
|
43 |
|
44 | build = program
|
45 | .command('build')
|
46 | .description(' - Build output file')
|
47 | .action (env)->
|
48 | task = ->
|
49 | logging.info "Executing command: 'build'"
|
50 | p = new Package opts
|
51 | p.build()
|
52 |
|
53 |
|
54 | program.parse process.argv
|
55 | if program.opt
|
56 | for opt, val of program.opts
|
57 | if val then opts[opt] = val
|
58 | else
|
59 | opts = program
|
60 |
|
61 | logging.setColor program.color
|
62 | if program.verbose
|
63 | logging.setLevel 'debug'
|
64 | if program.quiet
|
65 | logging.setClean true
|
66 | logging.setLevel 'critical'
|
67 |
|
68 | task()
|