UNPKG

2.91 kBJavaScriptView Raw
1var applyDefaults, defaults, log, lsr, sourceDirectoryPath, targetDirectoryPath, testDirectoryPath;
2
3log = require("id-debug");
4
5lsr = require("lsr");
6
7defaults = {};
8
9sourceDirectoryPath = "src";
10
11targetDirectoryPath = "build";
12
13testDirectoryPath = "test";
14
15defaults.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
23defaults.clean = {
24 enabled: true,
25 targetDirectoryPath: targetDirectoryPath
26};
27
28defaults.coffee = {
29 enabled: true,
30 sourceDirectoryPath: sourceDirectoryPath,
31 targetDirectoryPath: targetDirectoryPath
32};
33
34defaults.copy = {
35 enabled: true,
36 excluded: ["**/*.coffee", "**/*.less"],
37 sourceDirectoryPath: sourceDirectoryPath,
38 targetDirectoryPath: targetDirectoryPath
39};
40
41defaults.documentation = {
42 enabled: true,
43 sourceDirectoryPath: sourceDirectoryPath,
44 targetDirectoryPath: targetDirectoryPath
45};
46
47defaults.less = {
48 enabled: true,
49 entryFilePath: "" + sourceDirectoryPath + "/client/less/app.less",
50 targetDirectoryPath: "" + targetDirectoryPath + "/client/css"
51};
52
53defaults.livereload = {
54 enabled: true
55};
56
57defaults.nodemon = {
58 enabled: true,
59 entryFilePath: "app.js",
60 watchGlob: ["" + targetDirectoryPath + "/server/**/*.js"]
61};
62
63defaults.forever = {
64 enabled: true,
65 entryFilePath: "app.js",
66 watchDirectoryPath: sourceDirectoryPath
67};
68
69defaults.tests = {
70 enabled: true,
71 directoryPath: "test"
72};
73
74defaults.watch = {
75 enabled: true,
76 sourceDirectoryPath: sourceDirectoryPath,
77 testDirectoryPath: testDirectoryPath
78};
79
80applyDefaults = 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
109module.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};