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