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