1 | log = require "id-debug"
|
2 | lsr = require "lsr"
|
3 |
|
4 | defaults = {}
|
5 |
|
6 | sourceDirectoryPath = "src"
|
7 | targetDirectoryPath = "build"
|
8 | testDirectoryPath = "test"
|
9 |
|
10 | defaults.browserify =
|
11 | enabled: true
|
12 | paths: [ "#{targetDirectoryPath}/client/js/app" ]
|
13 | entryFilePath: "#{targetDirectoryPath}/client/js/app/app.js"
|
14 | targetFilename: "app.bundle.js"
|
15 | targetDirectoryPath: "#{targetDirectoryPath}/client/js/app"
|
16 |
|
17 | defaults.clean =
|
18 | enabled: true
|
19 | targetDirectoryPath: targetDirectoryPath
|
20 |
|
21 | defaults.coffee =
|
22 | enabled: true
|
23 | sourceDirectoryPath: sourceDirectoryPath
|
24 | targetDirectoryPath: targetDirectoryPath
|
25 |
|
26 | defaults.copy =
|
27 | enabled: true
|
28 | excluded: [ "**/*.coffee", "**/*.less" ]
|
29 | sourceDirectoryPath: sourceDirectoryPath
|
30 | targetDirectoryPath: targetDirectoryPath
|
31 |
|
32 | defaults.documentation =
|
33 | enabled: true
|
34 | sourceDirectoryPath: sourceDirectoryPath
|
35 | targetDirectoryPath: targetDirectoryPath
|
36 |
|
37 | defaults.less =
|
38 | enabled: true
|
39 | entryFilePath: "#{sourceDirectoryPath}/client/less/app.less"
|
40 | targetDirectoryPath: "#{targetDirectoryPath}/client/css"
|
41 |
|
42 | defaults.livereload =
|
43 | enabled: true
|
44 |
|
45 | defaults.nodemon =
|
46 | enabled: true
|
47 | entryFilePath: "app.js"
|
48 | watchGlob: [ "#{targetDirectoryPath}/server/**/*.js" ]
|
49 |
|
50 | defaults.forever =
|
51 | enabled: true
|
52 | entryFilePath: "app.js"
|
53 | watchDirectoryPath: sourceDirectoryPath
|
54 |
|
55 | defaults.tests =
|
56 | enabled: true
|
57 | directoryPath: "test"
|
58 |
|
59 | defaults.watch =
|
60 | enabled: true
|
61 | sourceDirectoryPath: sourceDirectoryPath
|
62 | testDirectoryPath: testDirectoryPath
|
63 |
|
64 | applyDefaults = (options) ->
|
65 | for task, taskOptions of defaults
|
66 | if typeof taskOptions is "object"
|
67 | for k, v of taskOptions
|
68 | unless options[task]?
|
69 | options[task] = {}
|
70 |
|
71 | unless options[task][k]?
|
72 | options[task][k] = v
|
73 | else
|
74 | options[task] = taskOptions
|
75 |
|
76 | module.exports = (options = {}) ->
|
77 | tasksDirectoryPath = "#{__dirname}/tasks"
|
78 |
|
79 | applyDefaults options
|
80 |
|
81 | global.idProjectOptions = options
|
82 |
|
83 | stats = lsr.sync tasksDirectoryPath
|
84 |
|
85 | for stat in stats
|
86 | unless stat.isDirectory()
|
87 | log.debug "Requiring module", stat.fullPath
|
88 |
|
89 | require stat.fullPath
|
90 |
|
91 | return
|