UNPKG

2.28 kBtext/coffeescriptView Raw
1log = require "./lib/log"
2lsr = require "lsr"
3
4defaults = {}
5
6sourceDirectoryPath = "src"
7targetDirectoryPath = "build"
8testDirectoryPath = "test"
9sourceClientDirectoryPath = "#{sourceDirectoryPath}/client"
10sourceServerDirectoryPath = "#{sourceDirectoryPath}/server"
11targetClientDirectoryPath = "#{targetDirectoryPath}/client"
12targetServerDirectoryPath = "#{targetDirectoryPath}/server"
13
14defaults.browserify =
15 enabled: true
16 entryFilePath: "#{targetDirectoryPath}/client/js/app.js"
17 targetFilename: "app.bundle.js"
18 targetDirectoryPath: "#{targetClientDirectoryPath}/js"
19
20defaults.clean =
21 enabled: true
22 targetDirectoryPath: targetDirectoryPath
23
24defaults.coffee =
25 enabled: true
26 sourceDirectoryPath: sourceDirectoryPath
27 targetDirectoryPath: targetDirectoryPath
28
29defaults.copy =
30 enabled: true
31 excluded: [ "**/*.coffee", "**/*.less" ]
32 sourceDirectoryPath: sourceDirectoryPath
33 targetDirectoryPath: targetDirectoryPath
34
35defaults.documentation =
36 enabled: true
37 sourceDirectoryPath: sourceDirectoryPath
38 targetDirectoryPath: targetDirectoryPath
39
40defaults.less =
41 enabled: true
42 entryFilePath: "#{sourceClientDirectoryPath}/less/app.less"
43 targetDirectoryPath: "#{targetClientDirectoryPath}/css"
44
45defaults.livereload =
46 enabled: true
47
48defaults.forever =
49 enabled: true
50 entryFilePath: "app.js"
51 watchDirectoryPath: sourceServerDirectoryPath
52
53defaults.tests =
54 enabled: true
55 directoryPath: "test"
56
57defaults.watch =
58 enabled: true
59 sourceDirectoryPath: sourceDirectoryPath
60 testDirectoryPath: testDirectoryPath
61
62applyDefaults = (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
74module.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