1 | var applyDefaults, defaults, log, lsr, sourceDirectoryPath, targetDirectoryPath, testDirectoryPath;
|
2 |
|
3 | log = require("id-debug");
|
4 |
|
5 | lsr = require("lsr");
|
6 |
|
7 | defaults = {};
|
8 |
|
9 | sourceDirectoryPath = "src";
|
10 |
|
11 | targetDirectoryPath = "build";
|
12 |
|
13 | testDirectoryPath = "test";
|
14 |
|
15 | defaults.browserify = {
|
16 | enabled: true,
|
17 | paths: ["" + targetDirectoryPath + "/client/js/app"],
|
18 | entryFilePath: "" + targetDirectoryPath + "/client/js/app/app.js",
|
19 | targetFilename: "app.bundle.js",
|
20 | targetDirectoryPath: "" + targetDirectoryPath + "/client/js/app"
|
21 | };
|
22 |
|
23 | defaults.clean = {
|
24 | enabled: true,
|
25 | targetDirectoryPath: targetDirectoryPath
|
26 | };
|
27 |
|
28 | defaults.coffee = {
|
29 | enabled: true,
|
30 | sourceDirectoryPath: sourceDirectoryPath,
|
31 | targetDirectoryPath: targetDirectoryPath
|
32 | };
|
33 |
|
34 | defaults.copy = {
|
35 | enabled: true,
|
36 | excluded: ["**/*.coffee", "**/*.less"],
|
37 | sourceDirectoryPath: sourceDirectoryPath,
|
38 | targetDirectoryPath: targetDirectoryPath
|
39 | };
|
40 |
|
41 | defaults.documentation = {
|
42 | enabled: true,
|
43 | sourceDirectoryPath: sourceDirectoryPath,
|
44 | targetDirectoryPath: targetDirectoryPath
|
45 | };
|
46 |
|
47 | defaults.less = {
|
48 | enabled: true,
|
49 | entryFilePath: "" + sourceDirectoryPath + "/client/less/app.less",
|
50 | targetDirectoryPath: "" + targetDirectoryPath + "/client/css"
|
51 | };
|
52 |
|
53 | defaults.livereload = {
|
54 | enabled: true
|
55 | };
|
56 |
|
57 | defaults.nodemon = {
|
58 | enabled: true,
|
59 | entryFilePath: "app.js",
|
60 | watchGlob: ["" + targetDirectoryPath + "/server/**/*.js"]
|
61 | };
|
62 |
|
63 | defaults.forever = {
|
64 | enabled: true,
|
65 | entryFilePath: "app.js",
|
66 | watchDirectoryPath: sourceDirectoryPath
|
67 | };
|
68 |
|
69 | defaults.tests = {
|
70 | enabled: true,
|
71 | directoryPath: "test"
|
72 | };
|
73 |
|
74 | defaults.watch = {
|
75 | enabled: true,
|
76 | sourceDirectoryPath: sourceDirectoryPath,
|
77 | testDirectoryPath: testDirectoryPath
|
78 | };
|
79 |
|
80 | applyDefaults = function(options) {
|
81 | var k, task, taskOptions, v, _results;
|
82 | _results = [];
|
83 | for (task in defaults) {
|
84 | taskOptions = defaults[task];
|
85 | if (typeof taskOptions === "object") {
|
86 | _results.push((function() {
|
87 | var _results1;
|
88 | _results1 = [];
|
89 | for (k in taskOptions) {
|
90 | v = taskOptions[k];
|
91 | if (options[task] == null) {
|
92 | options[task] = {};
|
93 | }
|
94 | if (options[task][k] == null) {
|
95 | _results1.push(options[task][k] = v);
|
96 | } else {
|
97 | _results1.push(void 0);
|
98 | }
|
99 | }
|
100 | return _results1;
|
101 | })());
|
102 | } else {
|
103 | _results.push(options[task] = taskOptions);
|
104 | }
|
105 | }
|
106 | return _results;
|
107 | };
|
108 |
|
109 | module.exports = function(options) {
|
110 | var stat, stats, tasksDirectoryPath, _i, _len;
|
111 | if (options == null) {
|
112 | options = {};
|
113 | }
|
114 | tasksDirectoryPath = "" + __dirname + "/tasks";
|
115 | applyDefaults(options);
|
116 | global.idProjectOptions = options;
|
117 | stats = lsr.sync(tasksDirectoryPath);
|
118 | for (_i = 0, _len = stats.length; _i < _len; _i++) {
|
119 | stat = stats[_i];
|
120 | if (!stat.isDirectory()) {
|
121 | log.debug("Requiring module", stat.fullPath);
|
122 | require(stat.fullPath);
|
123 | }
|
124 | }
|
125 | };
|