1 | exports.run=()-> new Toaster
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | exports.toaster = toaster
|
7 | exports.Toaster = class Toaster
|
8 |
|
9 |
|
10 | fs = require "fs"
|
11 | path = require "path"
|
12 | pn = path.normalize
|
13 | exec = (require "child_process").exec
|
14 | colors = require 'colors'
|
15 |
|
16 | constructor:( basedir, options = null, skip_initial_build = false )->
|
17 |
|
18 | @basepath = basedir || path.resolve "."
|
19 | @cli = new toaster.Cli options
|
20 |
|
21 | if options?
|
22 | for k, v of options
|
23 | @cli.argv[k] = v
|
24 |
|
25 |
|
26 | if @cli.argv.v
|
27 | filepath = pn __dirname + "/../package.json"
|
28 | contents = fs.readFileSync( filepath, "utf-8" )
|
29 | schema = JSON.parse( contents )
|
30 | return log schema.version
|
31 |
|
32 |
|
33 | else if @cli.argv.n
|
34 | new toaster.generators.Project( @basepath ).create @cli.argv.n
|
35 |
|
36 |
|
37 | else if @cli.argv.i
|
38 | new toaster.generators.Config( @basepath ).create @cli.argv.i
|
39 |
|
40 |
|
41 | else if @cli.argv.w
|
42 | config = if options and options.config then options.config else null
|
43 | @toast = new toaster.Toast @
|
44 | @build() unless skip_initial_build
|
45 |
|
46 |
|
47 | else
|
48 | return log @cli.opts.help()
|
49 |
|
50 | build:( header_code = "", footer_code = "" )->
|
51 | for builder in @toast.builders
|
52 | builder.build header_code, footer_code |
\ | No newline at end of file |