diff --git a/lib/toaster.js b/lib/toaster.js index 171a294..897f448 100644 --- a/lib/toaster.js +++ b/lib/toaster.js @@ -522,22 +522,25 @@ Builder.prototype._build_ns_tree = function(tree, folderpath) { - var folder, folders, include, item, _i, _j, _len, _len1, _ref, _results; + var file, include, item, _i, _j, _len, _len1, _ref, _ref1, _results; if (!fs.lstatSync(folderpath).isDirectory()) { return; } - folders = fsu.ls(folderpath); + _ref = fsu.ls(folderpath); _results = []; - for (_i = 0, _len = folders.length; _i < _len; _i++) { - folder = folders[_i]; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + file = _ref[_i]; + if (!fs.lstatSync(file).isDirectory()) { + continue; + } include = true; - _ref = this.exclude; - for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { - item = _ref[_j]; - include &= !(new RegExp(item).test(folder)); + _ref1 = this.exclude; + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + item = _ref1[_j]; + include &= !(new RegExp(item).test(file)); } if (include) { - _results.push(this._build_ns_tree((tree[folder.match(/[^\/\\]+$/m)] = {}), folder)); + _results.push(this._build_ns_tree((tree[file.match(/[^\/\\]+$/m)] = {}), file)); } else { _results.push(void 0); } diff --git a/src/toaster/core/builder.coffee b/src/toaster/core/builder.coffee index 1bc1373..6ab2a96 100644 --- a/src/toaster/core/builder.coffee +++ b/src/toaster/core/builder.coffee @@ -107,7 +107,7 @@ class Builder tree = {} for folder in @config.src_folders t = (tree[folder.alias] = {}) if folder.alias? - @_build_ns_tree t || tree, folder.path + @_build_ns_tree(t || tree, folder.path) buffer = "" for name, scope of tree @@ -123,13 +123,13 @@ class Builder ### _build_ns_tree: (tree, folderpath) -> return unless fs.lstatSync(folderpath).isDirectory() - folders = fsu.ls(folderpath) - for folder in folders + for file in fsu.ls(folderpath) + continue unless fs.lstatSync(file).isDirectory() include = true for item in @exclude - include &= !(new RegExp( item ).test folder) + include &= !(new RegExp(item).test file) if include - @_build_ns_tree (tree[folder.match /[^\/\\]+$/m] = {}), folder + @_build_ns_tree((tree[file.match /[^\/\\]+$/m] = {}), file) ### @return {String} diff --git a/test/coverage.html b/test/coverage.html index d74119c..dba6661 100644 --- a/test/coverage.html +++ b/test/coverage.html @@ -338,4 +338,4 @@ code .string { color: #5890AD } code .keyword { color: #8A6343 } code .number { color: #2F6FAD } -

Coverage

78%
417
329
88

/Users/franklin/Workspaces/node/node-coffee-toaster-api/lib/toaster.js

78%
417
329
88
LineHitsSource
11(function() {
21 var ArrayUtil, Builder, Script, Toast, Toaster, error, log, warn,
36 __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
4
51 Toast = (function() {
61 var fs, path;
7
81 fs = require("fs");
9
101 path = require("path");
11
121 Toast.prototype.basepath = null;
13
141 Toast.prototype.builders = null;
15
161 function Toast(basepath, options) {
173 var item, _i, _len, _ref;
183 this.basepath = basepath;
193 this._toast = __bind(this._toast, this);
203 this.builders = [];
213 _ref = [].concat(options);
223 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
233 item = _ref[_i];
243 this._toast(item);
25 }
26 }
27
281 Toast.prototype._toast = function(srcpath, params) {
293 var alias, builder, config, folder, i, item, v, vpath, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
303 if (params == null) {
313 params = {};
32 }
333 if (srcpath instanceof Object) {
343 params = srcpath;
350 } else if ((path.resolve(srcpath)) !== srcpath) {
360 folder = path.join(this.basepath, srcpath);
37 }
383 if (params.release == null) {
390 error('Release path not informed in config.');
400 return process.exit();
41 }
423 if (!fs.existsSync(path.join(this.basepath, path.dirname(params.release)))) {
430 error("Release folder does not exist:\n\t" + dir.yellow);
440 return process.exit();
45 }
463 config = {
47 is_building: false,
48 basepath: this.basepath,
49 src_folders: [],
50 files: [],
51 vendors: (_ref = params.vendors) != null ? _ref : [],
52 exclude: (_ref1 = params.exclude) != null ? _ref1 : [],
53 bare: (_ref2 = params.bare) != null ? _ref2 : false,
54 packaging: (_ref3 = params.packaging) != null ? _ref3 : true,
55 expose: (_ref4 = params.expose) != null ? _ref4 : null,
56 minify: (_ref5 = params.minify) != null ? _ref5 : true,
57 callback: (_ref6 = params.callback) != null ? _ref6 : null,
58 release: path.join(this.basepath, params.release)
59 };
603 _ref7 = config.vendors;
613 for (i = _i = 0, _len = _ref7.length; _i < _len; i = ++_i) {
623 v = _ref7[i];
633 vpath = config.vendors[i] = path.resolve(v);
643 if ((path.resolve(vpath)) !== vpath) {
650 config.vendors[i] = path.join(this.basepath, v);
66 }
67 }
683 if (!(srcpath instanceof Object)) {
690 srcpath = path.resolve(path.join(this.basepath, srcpath));
700 config.src_folders.push({
71 path: srcpath,
72 alias: params.alias || null
73 });
74 }
753 if (params.folders != null) {
763 _ref8 = params.folders;
773 for (folder in _ref8) {
783 alias = _ref8[folder];
793 if ((path.resolve(folder)) !== folder) {
803 folder = path.join(this.basepath, folder);
81 }
823 config.src_folders.push({
83 path: folder,
84 alias: alias
85 });
86 }
87 }
883 _ref9 = config.src_folders;
893 for (_j = 0, _len1 = _ref9.length; _j < _len1; _j++) {
903 item = _ref9[_j];
913 if (!fs.existsSync(item.path)) {
920 error(("Source folder doens't exist:\n\t" + item.path.red + "\n") + ("Check your " + 'toaster.coffee'.yellow + " and try again.") + "\n\t" + (path.join(this.basepath, "toaster.coffee")).yellow);
930 return process.exit();
94 }
95 }
963 builder = new Builder(this.basepath, config);
973 return this.builders.push(builder);
98 };
99
1001 return Toast;
101
102 })();
103
1041 ArrayUtil = (function() {
1051 function ArrayUtil() {}
106
107 /*
108 @param {Array} source
109 @param {Object} search
110 @param {String} by_property
111 @return {Boolean}
112 */
113
114
1151 ArrayUtil.has = function(source, search, by_property) {
1163 return ArrayUtil.find(source, search, by_property) != null;
117 };
118
119 /*
120 @param {Array} source
121 @param {Object} search
122 @param {String} by_property
123 @return {Object}
124 */
125
126
1271 ArrayUtil.find = function(source, search, by_property) {
12839 var k, p, v, _i, _j, _k, _len, _len1, _len2;
12939 if (!by_property) {
1303 for (k = _i = 0, _len = source.length; _i < _len; k = ++_i) {
1310 v = source[k];
1320 if (v === search) {
1330 return {
134 item: v,
135 index: k
136 };
137 }
138 }
139 } else {
14036 by_property = [].concat(by_property);
14136 for (k = _j = 0, _len1 = source.length; _j < _len1; k = ++_j) {
14266 v = source[k];
14366 for (_k = 0, _len2 = by_property.length; _k < _len2; _k++) {
14466 p = by_property[_k];
14566 if (search === v[p]) {
14636 return {
147 item: v,
148 index: k
149 };
150 }
151 }
152 }
153 }
1543 return null;
155 };
156
157 /*
158 @param {Array} source
159 @param {Object} search
160 @param {String} by_property
161 @param {Boolean} regexp
162 @param {Boolean} unique
163 @return {Object}
164 */
165
166
1671 ArrayUtil.find_all = function(source, search, by_property, regexp, unique) {
1683 var item, k, p, v, _i, _j, _k, _len, _len1, _len2, _output, _unique;
1693 _output = [];
1703 _unique = {};
1713 if (by_property === null) {
1720 for (k = _i = 0, _len = source.length; _i < _len; k = ++_i) {
1730 v = source[k];
1740 if (regexp) {
1750 if (search.test(v)) {
1760 item = {
177 item: v,
178 index: k
179 };
180 }
181 } else {
1820 if (search === v) {
1830 item = {
184 item: v,
185 index: k
186 };
187 }
188 }
1890 if (item) {
1900 _output.push(item);
191 }
192 }
193 } else {
1943 by_property = [].concat(by_property);
1953 for (k = _j = 0, _len1 = source.length; _j < _len1; k = ++_j) {
1969 v = source[k];
1979 for (_k = 0, _len2 = by_property.length; _k < _len2; _k++) {
1989 p = by_property[_k];
1999 item = null;
2009 if (regexp) {
2019 if (search.test(v[p])) {
2029 if (unique && !_unique[k]) {
2039 item = {
204 item: v,
205 index: k
206 };
2070 } else if (unique === !true) {
2080 item = {
209 item: v,
210 index: k
211 };
212 }
213 }
214 } else {
2150 if (search === v[p]) {
2160 item = {
217 item: v,
218 index: k
219 };
220 }
221 }
2229 if (item) {
2239 _unique[k] = true;
2249 _output.push(item);
225 }
226 }
227 }
228 }
2293 return _output;
230 };
231
2321 return ArrayUtil;
233
234 })();
235
2361 Script = (function() {
2371 var cs, fs, path;
238
2391 fs = require("fs");
240
2411 path = require("path");
242
2431 cs = require("coffee-script");
244
2451 Script.prototype.builder = null;
246
2471 Script.prototype.folderpath = null;
248
2491 Script.prototype.realpath = null;
250
2511 Script.prototype.alias = null;
252
2531 Script.prototype.opts = null;
254
2551 Script.prototype.dependencies_collapsed = null;
256
2571 Script.prototype.raw = null;
258
2591 Script.prototype.baseclasses = null;
260
2611 Script.prototype.filepath = null;
262
2631 Script.prototype.filename = null;
264
2651 Script.prototype.filefolder = null;
266
2671 Script.prototype.namespace = null;
268
2691 function Script(builder, folderpath, realpath, alias) {
2709 this.builder = builder;
2719 this.folderpath = folderpath;
2729 this.realpath = realpath;
2739 this.alias = alias;
2749 this._getinfo();
275 }
276
277 /*
278 @return {Array}
279 */
280
281
2821 Script.prototype.expand_dependencies = function() {
2839 var dependency, expanded, files, found, index, reg, _i, _j, _len, _len1, _ref;
2849 files = this.builder.files;
2859 this.dependencies = [];
2869 _ref = this.dependencies_collapsed;
2879 for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) {
2886 dependency = _ref[index];
2896 if ((dependency.substr(0, 1)) === path.sep) {
2900 dependency = dependency.substr(1);
291 }
2926 if (dependency.substr(-1) !== "*") {
2933 this.dependencies.push("" + path.sep + dependency + ".coffee");
2943 continue;
295 }
2963 reg = new RegExp(dependency.replace(/(\/|\\)/g, "\\$1"));
2973 found = ArrayUtil.find_all(files, reg, "filepath", true, true);
2983 if (found.length <= 0) {
2990 warn(("Nothing found inside " + ("'" + dependency).white + "'").yellow);
3000 continue;
301 }
3023 for (_j = 0, _len1 = found.length; _j < _len1; _j++) {
3039 expanded = found[_j];
3049 if (expanded.item.filepath !== this.filepath) {
3056 this.dependencies.push(expanded.item.filepath);
306 }
307 }
308 }
3099 return this.dependencies;
310 };
311
312 /*
313 @param {Boolean} declare_ns
314 */
315
316
3171 Script.prototype._getinfo = function(declare_ns) {
3189 var baseclass, decl, extending, item, klass, name, repl, requirements, rgx, rgx_ext, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
3199 if (declare_ns == null) {
3209 declare_ns = true;
321 }
3229 this.raw = fs.readFileSync(this.realpath, "utf-8");
3239 this.dependencies_collapsed = [];
3249 this.baseclasses = [];
3259 this.filepath = this.realpath.replace(this.folderpath, '');
3269 if (this.alias != null) {
3279 this.filepath = path.join(path.sep, this.alias, this.filepath);
328 }
3299 this.filename = path.basename(this.filepath);
3309 this.filefolder = path.dirname(this.filepath);
3319 this.namespace = "";
3329 if (this.filepath.indexOf(path.sep) === -1) {
3330 this.filefolder = "";
334 }
3359 this.namespace = this.filefolder.replace(new RegExp("\\" + path.sep, "g"), ".");
3369 this.namespace = this.namespace.replace(/^\.?(.*)\.?$/g, "$1");
3379 rgx = /^(class)+\s+([^\s]+)+(\s(extends)\s+([\w.]+))?/mg;
3389 rgx_ext = /(^|=\s*)(class)\s(\w+)\s(extends)\s(\\w+)\s*$/gm;
3399 if (this.raw.match(rgx) != null) {
3409 if (this.namespace !== "" && this.builder.packaging) {
3410 _ref = [].concat(this.raw.match(rgx));
3420 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
3430 decl = _ref[_i];
3440 name = decl.match(/class\s([^\s]+)/);
3450 name = (name[1].split('.')).pop();
3460 extending = decl.match(/(\sextends\s[^\s]+$)/m);
3470 if (extending) {
3480 extending = extending[0];
349 }
3500 extending || (extending = "");
3510 repl = "class " + this.namespace + "." + name + extending;
3520 if (decl !== repl) {
3530 this.raw = this.raw.replace(decl, repl);
3540 fs.writeFileSync(this.realpath, this.raw);
355 }
356 }
3570 this.classpath = "" + this.namespace + "." + this.classname;
358 }
3599 this.classname = this.raw.match(rgx)[3];
3609 _ref2 = (_ref1 = this.raw.match(rgx_ext)) != null ? _ref1 : [];
3619 for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
3620 klass = _ref2[_j];
3630 baseclass = klass.match(rgx_ext)[5];
3640 this.baseclasses.push(baseclass);
365 }
366 }
3679 if (/(#<<\s)(.*)/g.test(this.raw)) {
3686 requirements = this.raw.match(/(#<<\s)(.*)/g);
3696 _results = [];
3706 for (_k = 0, _len2 = requirements.length; _k < _len2; _k++) {
3716 item = requirements[_k];
3726 item = /(#<<\s)(.*)/.exec(item)[2];
3736 item = item.replace(/\s/g, "");
3746 if (path.sep === "\\") {
3750 item = item.replace(/(\/)/g, "\\");
376 }
3776 _results.push(this.dependencies_collapsed = this.dependencies_collapsed.concat(item));
378 }
3796 return _results;
380 }
381 };
382
3831 return Script;
384
385 })();
386
3871 Builder = (function() {
3881 var cs, fs, fsu, path, uglify;
389
3901 fs = require('fs');
391
3921 path = require('path');
393
3941 fsu = require('fs-util');
395
3961 cs = require("coffee-script");
397
3981 uglify = require("uglify-js");
399
4001 Builder.prototype.missing = {};
401
4021 function Builder(basepath, config) {
4033 var falias, file, folder, fpath, include, item, result, s, _i, _j, _k, _len, _len1, _len2, _ref, _ref1;
4043 this.basepath = basepath;
4053 this.config = config;
4063 this.exclude = [].concat(this.config.exclude);
4073 this.files = this.config.files;
4083 _ref = this.config.src_folders;
4093 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
4103 folder = _ref[_i];
4113 result = fsu.find(folder.path, /.coffee$/m);
4123 fpath = folder.path;
4133 falias = folder.alias;
4143 for (_j = 0, _len1 = result.length; _j < _len1; _j++) {
4159 file = result[_j];
4169 include = true;
4179 _ref1 = this.exclude;
4189 for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
4190 item = _ref1[_k];
4200 include &= !(new RegExp(item).test(file));
421 }
4229 if (include) {
4239 s = new Script(this, fpath, file, falias);
4249 this.files.push(s);
425 }
426 }
427 }
428 }
429
4301 Builder.prototype.build = function(header_code, footer_code) {
4313 var contents, namespaces, options, vendors;
4323 if (header_code == null) {
4330 header_code = "";
434 }
4353 if (footer_code == null) {
4360 footer_code = "";
437 }
4383 namespaces = this._build_namespaces();
4393 vendors = this._merge_vendors();
4403 contents = [];
4413 if (this.config.packaging) {
4423 contents.push(namespaces);
443 }
4443 if (header_code !== "") {
4450 contents.push(header_code);
446 }
4473 contents.push(this._compile());
4483 if (header_code !== "") {
4490 contents.push(footer_code);
450 }
4513 contents = contents.join('\n');
4523 if (this.config.minify !== false) {
4532 if (this.config.minify === true) {
4540 options = {};
455 } else {
4562 options = this.config.minify;
457 }
4582 options.fromString = true;
4592 contents = uglify.minify(contents, options).code;
460 }
4613 if (this.config.callback != null) {
4621 contents = this.config.callback.apply(this, [contents, this.config.minify !== false]);
463 }
4643 if (vendors !== "") {
4653 contents = vendors + '\n' + contents;
466 }
4673 return fs.writeFileSync(this.config.release, contents);
468 };
469
470 /*
471 @return {String}
472 */
473
474
4751 Builder.prototype._merge_vendors = function() {
4763 var buffer, vendor, _i, _len, _ref;
4773 buffer = [];
4783 _ref = this.config.vendors;
4793 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
4803 vendor = _ref[_i];
4813 if (fs.existsSync(vendor)) {
4823 buffer.push(fs.readFileSync(vendor, 'utf-8'));
483 } else {
4840 warn("Vendor not found at ".white + vendor.yellow.bold);
485 }
486 }
4873 return buffer.join("\n");
488 };
489
490 /*
491 Creates a NS holder for all folders
492 */
493
494
4951 Builder.prototype._build_namespaces = function() {
4963 var buffer, folder, name, scope, t, tree, _i, _len, _ref;
4973 tree = {};
4983 _ref = this.config.src_folders;
4993 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
5003 folder = _ref[_i];
5013 if (folder.alias != null) {
5023 t = (tree[folder.alias] = {});
503 }
5043 this._build_ns_tree(t || tree, folder.path);
505 }
5063 buffer = "";
5073 for (name in tree) {
5083 scope = tree[name];
5093 buffer += "var " + name + " = ";
5103 if (this.config.expose != null) {
5110 buffer += "" + this.config.expose + "." + name + " = ";
512 }
5133 buffer += (JSON.stringify(scope, null, '')).replace(/\"/g, "'");
5143 buffer += ";\n";
515 }
5163 return buffer;
517 };
518
519 /*
520 Walk some folderpath and lists all its subfolders
521 */
522
523
5241 Builder.prototype._build_ns_tree = function(tree, folderpath) {
5256 var folder, folders, include, item, _i, _j, _len, _len1, _ref, _results;
5266 if (!fs.lstatSync(folderpath).isDirectory()) {
5270 return;
528 }
5296 folders = fsu.ls(folderpath);
5306 _results = [];
5316 for (_i = 0, _len = folders.length; _i < _len; _i++) {
5323 folder = folders[_i];
5333 include = true;
5343 _ref = this.exclude;
5353 for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
5360 item = _ref[_j];
5370 include &= !(new RegExp(item).test(folder));
538 }
5393 if (include) {
5403 _results.push(this._build_ns_tree((tree[folder.match(/[^\/\\]+$/m)] = {}), folder));
541 } else {
5420 _results.push(void 0);
543 }
544 }
5456 return _results;
546 };
547
548 /*
549 @return {String}
550 */
551
552
5531 Builder.prototype._compile = function() {
5543 var err, file, msg, output, _i, _j, _len, _len1, _ref, _ref1;
5553 _ref = this.files;
5563 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
5579 file = _ref[_i];
5589 try {
5599 cs.compile(file.raw);
560 } catch (_error) {
5610 err = _error;
5620 msg = err.message.replace('"', '\\"');
5630 msg = ("" + msg.white + " at file: ") + ("" + file.filepath).bold.red;
5640 error(msg);
5650 return null;
566 }
567 }
5683 _ref1 = this.files;
5693 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
5709 file = _ref1[_j];
5719 file.expand_dependencies();
572 }
5733 this._reorder();
5743 output = ((function() {
5753 var _k, _len2, _ref2, _results;
5763 _ref2 = this.files;
5773 _results = [];
5783 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
5799 file = _ref2[_k];
5809 _results.push(file.raw);
581 }
5823 return _results;
583 }).call(this)).join("\n");
5843 return output = cs.compile(output, {
585 bare: this.config.bare
586 });
587 };
588
589 /*
590 @param {Boolean} cycling
591 */
592
593
5941 Builder.prototype._reorder = function(cycling) {
5956 var bc, dependency, dependency_index, file, file_index, filepath, found, i, index, not_found, _i, _j, _len, _len1, _ref, _ref1, _results;
5966 if (cycling == null) {
5973 cycling = false;
598 }
5996 if (cycling === false) {
6003 this.missing = {};
601 }
6026 _ref = this.files;
6036 _results = [];
6046 for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
60518 file = _ref[i];
60618 if (!file.dependencies.length && !file.baseclasses.length) {
6073 continue;
608 }
60915 _ref1 = file.dependencies;
61015 for (index = _j = 0, _len1 = _ref1.length; _j < _len1; index = ++_j) {
61121 filepath = _ref1[index];
61221 dependency = ArrayUtil.find(this.files, filepath, "filepath");
61321 if (dependency != null) {
61421 dependency_index = dependency.index;
615 }
61621 if (dependency_index < i && (dependency != null)) {
61718 continue;
618 }
6193 if (dependency != null) {
6203 if (ArrayUtil.has(dependency.item.dependencies, file.filepath)) {
6210 file.dependencies.splice(index, 1);
6220 warn("Circular dependency found between ".yellow + filepath.grey.bold + " and ".yellow + file.filepath.grey.bold);
6230 continue;
624 } else {
6253 this.files.splice(index, 0, dependency.item);
6263 this.files.splice(dependency.index + 1, 1);
6273 this._reorder(true);
6283 break;
629 }
6300 } else if (this.missing[filepath] !== true) {
6310 this.missing[filepath] = true;
6320 file.dependencies.push(filepath);
6330 file.dependencies.splice(index, 1);
6340 warn("" + 'Dependency'.yellow + " " + filepath.bold.grey + " " + 'not found for file'.yellow + " " + file.filepath.grey.bold);
635 }
636 }
63715 file_index = ArrayUtil.find(this.files, file.filepath, "filepath");
63815 file_index = file_index.index;
63915 _results.push((function() {
64015 var _k, _len2, _ref2, _results1;
64115 _ref2 = file.baseclasses;
64215 _results1 = [];
64315 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
6440 bc = _ref2[_k];
6450 found = ArrayUtil.find(this.files, bc, "classname");
6460 not_found = (found === null) || (found.index > file_index);
6470 if (not_found && !this.missing[bc]) {
6480 this.missing[bc] = true;
6490 _results1.push(warn("Base class ".yellow + ("" + bc + " ").bold.grey + "not found for class ".yellow + ("" + file.classname + " ").bold.grey + "in file ".yellow + file.filepath.bold.grey));
650 } else {
6510 _results1.push(void 0);
652 }
653 }
65415 return _results1;
655 }).call(this));
656 }
6576 return _results;
658 };
659
6601 return Builder;
661
662 })();
663
6641 module.exports = Toaster = (function() {
6651 var path;
666
6671 path = require("path");
668
669 /*
670 @var {Cli}
671 */
672
673
6741 Toaster.prototype.options = null;
675
676 /*
677 @var {Object} before filter container
678 */
679
680
6811 Toaster.prototype.before_build = null;
682
6831 function Toaster(basedir, options) {
6843 this.toast = new Toast(path.resolve(basedir), options);
685 }
686
6871 Toaster.prototype.build = function(header_code, footer_code) {
6883 var builder, _i, _len, _ref, _results;
6893 if (header_code == null) {
6903 header_code = "";
691 }
6923 if (footer_code == null) {
6933 footer_code = "";
694 }
6953 _ref = this.toast.builders;
6963 _results = [];
6973 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
6983 builder = _ref[_i];
6993 _results.push(builder.build(header_code, footer_code));
700 }
7013 return _results;
702 };
703
7041 return Toaster;
705
706 })();
707
7081 log = function(msg) {
7090 console.log(msg);
7100 return msg;
711 };
712
7131 error = function(msg) {
7140 msg = log("ERROR ".bold.red + msg);
7150 return msg;
716 };
717
7181 warn = function(msg) {
7190 msg = log("WARNING ".bold.yellow + msg);
7200 return msg;
721 };
722
723}).call(this);
724
\ No newline at end of file +

Coverage

78%
419
331
88

/Users/franklin/Workspaces/node/node-coffee-toaster-api/lib/toaster.js

78%
419
331
88
LineHitsSource
11(function() {
21 var ArrayUtil, Builder, Script, Toast, Toaster, error, log, warn,
36 __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
4
51 Toast = (function() {
61 var fs, path;
7
81 fs = require("fs");
9
101 path = require("path");
11
121 Toast.prototype.basepath = null;
13
141 Toast.prototype.builders = null;
15
161 function Toast(basepath, options) {
173 var item, _i, _len, _ref;
183 this.basepath = basepath;
193 this._toast = __bind(this._toast, this);
203 this.builders = [];
213 _ref = [].concat(options);
223 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
233 item = _ref[_i];
243 this._toast(item);
25 }
26 }
27
281 Toast.prototype._toast = function(srcpath, params) {
293 var alias, builder, config, folder, i, item, v, vpath, _i, _j, _len, _len1, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
303 if (params == null) {
313 params = {};
32 }
333 if (srcpath instanceof Object) {
343 params = srcpath;
350 } else if ((path.resolve(srcpath)) !== srcpath) {
360 folder = path.join(this.basepath, srcpath);
37 }
383 if (params.release == null) {
390 error('Release path not informed in config.');
400 return process.exit();
41 }
423 if (!fs.existsSync(path.join(this.basepath, path.dirname(params.release)))) {
430 error("Release folder does not exist:\n\t" + dir.yellow);
440 return process.exit();
45 }
463 config = {
47 is_building: false,
48 basepath: this.basepath,
49 src_folders: [],
50 files: [],
51 vendors: (_ref = params.vendors) != null ? _ref : [],
52 exclude: (_ref1 = params.exclude) != null ? _ref1 : [],
53 bare: (_ref2 = params.bare) != null ? _ref2 : false,
54 packaging: (_ref3 = params.packaging) != null ? _ref3 : true,
55 expose: (_ref4 = params.expose) != null ? _ref4 : null,
56 minify: (_ref5 = params.minify) != null ? _ref5 : true,
57 callback: (_ref6 = params.callback) != null ? _ref6 : null,
58 release: path.join(this.basepath, params.release)
59 };
603 _ref7 = config.vendors;
613 for (i = _i = 0, _len = _ref7.length; _i < _len; i = ++_i) {
623 v = _ref7[i];
633 vpath = config.vendors[i] = path.resolve(v);
643 if ((path.resolve(vpath)) !== vpath) {
650 config.vendors[i] = path.join(this.basepath, v);
66 }
67 }
683 if (!(srcpath instanceof Object)) {
690 srcpath = path.resolve(path.join(this.basepath, srcpath));
700 config.src_folders.push({
71 path: srcpath,
72 alias: params.alias || null
73 });
74 }
753 if (params.folders != null) {
763 _ref8 = params.folders;
773 for (folder in _ref8) {
783 alias = _ref8[folder];
793 if ((path.resolve(folder)) !== folder) {
803 folder = path.join(this.basepath, folder);
81 }
823 config.src_folders.push({
83 path: folder,
84 alias: alias
85 });
86 }
87 }
883 _ref9 = config.src_folders;
893 for (_j = 0, _len1 = _ref9.length; _j < _len1; _j++) {
903 item = _ref9[_j];
913 if (!fs.existsSync(item.path)) {
920 error(("Source folder doens't exist:\n\t" + item.path.red + "\n") + ("Check your " + 'toaster.coffee'.yellow + " and try again.") + "\n\t" + (path.join(this.basepath, "toaster.coffee")).yellow);
930 return process.exit();
94 }
95 }
963 builder = new Builder(this.basepath, config);
973 return this.builders.push(builder);
98 };
99
1001 return Toast;
101
102 })();
103
1041 ArrayUtil = (function() {
1051 function ArrayUtil() {}
106
107 /*
108 @param {Array} source
109 @param {Object} search
110 @param {String} by_property
111 @return {Boolean}
112 */
113
114
1151 ArrayUtil.has = function(source, search, by_property) {
1163 return ArrayUtil.find(source, search, by_property) != null;
117 };
118
119 /*
120 @param {Array} source
121 @param {Object} search
122 @param {String} by_property
123 @return {Object}
124 */
125
126
1271 ArrayUtil.find = function(source, search, by_property) {
12839 var k, p, v, _i, _j, _k, _len, _len1, _len2;
12939 if (!by_property) {
1303 for (k = _i = 0, _len = source.length; _i < _len; k = ++_i) {
1310 v = source[k];
1320 if (v === search) {
1330 return {
134 item: v,
135 index: k
136 };
137 }
138 }
139 } else {
14036 by_property = [].concat(by_property);
14136 for (k = _j = 0, _len1 = source.length; _j < _len1; k = ++_j) {
14266 v = source[k];
14366 for (_k = 0, _len2 = by_property.length; _k < _len2; _k++) {
14466 p = by_property[_k];
14566 if (search === v[p]) {
14636 return {
147 item: v,
148 index: k
149 };
150 }
151 }
152 }
153 }
1543 return null;
155 };
156
157 /*
158 @param {Array} source
159 @param {Object} search
160 @param {String} by_property
161 @param {Boolean} regexp
162 @param {Boolean} unique
163 @return {Object}
164 */
165
166
1671 ArrayUtil.find_all = function(source, search, by_property, regexp, unique) {
1683 var item, k, p, v, _i, _j, _k, _len, _len1, _len2, _output, _unique;
1693 _output = [];
1703 _unique = {};
1713 if (by_property === null) {
1720 for (k = _i = 0, _len = source.length; _i < _len; k = ++_i) {
1730 v = source[k];
1740 if (regexp) {
1750 if (search.test(v)) {
1760 item = {
177 item: v,
178 index: k
179 };
180 }
181 } else {
1820 if (search === v) {
1830 item = {
184 item: v,
185 index: k
186 };
187 }
188 }
1890 if (item) {
1900 _output.push(item);
191 }
192 }
193 } else {
1943 by_property = [].concat(by_property);
1953 for (k = _j = 0, _len1 = source.length; _j < _len1; k = ++_j) {
1969 v = source[k];
1979 for (_k = 0, _len2 = by_property.length; _k < _len2; _k++) {
1989 p = by_property[_k];
1999 item = null;
2009 if (regexp) {
2019 if (search.test(v[p])) {
2029 if (unique && !_unique[k]) {
2039 item = {
204 item: v,
205 index: k
206 };
2070 } else if (unique === !true) {
2080 item = {
209 item: v,
210 index: k
211 };
212 }
213 }
214 } else {
2150 if (search === v[p]) {
2160 item = {
217 item: v,
218 index: k
219 };
220 }
221 }
2229 if (item) {
2239 _unique[k] = true;
2249 _output.push(item);
225 }
226 }
227 }
228 }
2293 return _output;
230 };
231
2321 return ArrayUtil;
233
234 })();
235
2361 Script = (function() {
2371 var cs, fs, path;
238
2391 fs = require("fs");
240
2411 path = require("path");
242
2431 cs = require("coffee-script");
244
2451 Script.prototype.builder = null;
246
2471 Script.prototype.folderpath = null;
248
2491 Script.prototype.realpath = null;
250
2511 Script.prototype.alias = null;
252
2531 Script.prototype.opts = null;
254
2551 Script.prototype.dependencies_collapsed = null;
256
2571 Script.prototype.raw = null;
258
2591 Script.prototype.baseclasses = null;
260
2611 Script.prototype.filepath = null;
262
2631 Script.prototype.filename = null;
264
2651 Script.prototype.filefolder = null;
266
2671 Script.prototype.namespace = null;
268
2691 function Script(builder, folderpath, realpath, alias) {
2709 this.builder = builder;
2719 this.folderpath = folderpath;
2729 this.realpath = realpath;
2739 this.alias = alias;
2749 this._getinfo();
275 }
276
277 /*
278 @return {Array}
279 */
280
281
2821 Script.prototype.expand_dependencies = function() {
2839 var dependency, expanded, files, found, index, reg, _i, _j, _len, _len1, _ref;
2849 files = this.builder.files;
2859 this.dependencies = [];
2869 _ref = this.dependencies_collapsed;
2879 for (index = _i = 0, _len = _ref.length; _i < _len; index = ++_i) {
2886 dependency = _ref[index];
2896 if ((dependency.substr(0, 1)) === path.sep) {
2900 dependency = dependency.substr(1);
291 }
2926 if (dependency.substr(-1) !== "*") {
2933 this.dependencies.push("" + path.sep + dependency + ".coffee");
2943 continue;
295 }
2963 reg = new RegExp(dependency.replace(/(\/|\\)/g, "\\$1"));
2973 found = ArrayUtil.find_all(files, reg, "filepath", true, true);
2983 if (found.length <= 0) {
2990 warn(("Nothing found inside " + ("'" + dependency).white + "'").yellow);
3000 continue;
301 }
3023 for (_j = 0, _len1 = found.length; _j < _len1; _j++) {
3039 expanded = found[_j];
3049 if (expanded.item.filepath !== this.filepath) {
3056 this.dependencies.push(expanded.item.filepath);
306 }
307 }
308 }
3099 return this.dependencies;
310 };
311
312 /*
313 @param {Boolean} declare_ns
314 */
315
316
3171 Script.prototype._getinfo = function(declare_ns) {
3189 var baseclass, decl, extending, item, klass, name, repl, requirements, rgx, rgx_ext, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
3199 if (declare_ns == null) {
3209 declare_ns = true;
321 }
3229 this.raw = fs.readFileSync(this.realpath, "utf-8");
3239 this.dependencies_collapsed = [];
3249 this.baseclasses = [];
3259 this.filepath = this.realpath.replace(this.folderpath, '');
3269 if (this.alias != null) {
3279 this.filepath = path.join(path.sep, this.alias, this.filepath);
328 }
3299 this.filename = path.basename(this.filepath);
3309 this.filefolder = path.dirname(this.filepath);
3319 this.namespace = "";
3329 if (this.filepath.indexOf(path.sep) === -1) {
3330 this.filefolder = "";
334 }
3359 this.namespace = this.filefolder.replace(new RegExp("\\" + path.sep, "g"), ".");
3369 this.namespace = this.namespace.replace(/^\.?(.*)\.?$/g, "$1");
3379 rgx = /^(class)+\s+([^\s]+)+(\s(extends)\s+([\w.]+))?/mg;
3389 rgx_ext = /(^|=\s*)(class)\s(\w+)\s(extends)\s(\\w+)\s*$/gm;
3399 if (this.raw.match(rgx) != null) {
3409 if (this.namespace !== "" && this.builder.packaging) {
3410 _ref = [].concat(this.raw.match(rgx));
3420 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
3430 decl = _ref[_i];
3440 name = decl.match(/class\s([^\s]+)/);
3450 name = (name[1].split('.')).pop();
3460 extending = decl.match(/(\sextends\s[^\s]+$)/m);
3470 if (extending) {
3480 extending = extending[0];
349 }
3500 extending || (extending = "");
3510 repl = "class " + this.namespace + "." + name + extending;
3520 if (decl !== repl) {
3530 this.raw = this.raw.replace(decl, repl);
3540 fs.writeFileSync(this.realpath, this.raw);
355 }
356 }
3570 this.classpath = "" + this.namespace + "." + this.classname;
358 }
3599 this.classname = this.raw.match(rgx)[3];
3609 _ref2 = (_ref1 = this.raw.match(rgx_ext)) != null ? _ref1 : [];
3619 for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
3620 klass = _ref2[_j];
3630 baseclass = klass.match(rgx_ext)[5];
3640 this.baseclasses.push(baseclass);
365 }
366 }
3679 if (/(#<<\s)(.*)/g.test(this.raw)) {
3686 requirements = this.raw.match(/(#<<\s)(.*)/g);
3696 _results = [];
3706 for (_k = 0, _len2 = requirements.length; _k < _len2; _k++) {
3716 item = requirements[_k];
3726 item = /(#<<\s)(.*)/.exec(item)[2];
3736 item = item.replace(/\s/g, "");
3746 if (path.sep === "\\") {
3750 item = item.replace(/(\/)/g, "\\");
376 }
3776 _results.push(this.dependencies_collapsed = this.dependencies_collapsed.concat(item));
378 }
3796 return _results;
380 }
381 };
382
3831 return Script;
384
385 })();
386
3871 Builder = (function() {
3881 var cs, fs, fsu, path, uglify;
389
3901 fs = require('fs');
391
3921 path = require('path');
393
3941 fsu = require('fs-util');
395
3961 cs = require("coffee-script");
397
3981 uglify = require("uglify-js");
399
4001 Builder.prototype.missing = {};
401
4021 function Builder(basepath, config) {
4033 var falias, file, folder, fpath, include, item, result, s, _i, _j, _k, _len, _len1, _len2, _ref, _ref1;
4043 this.basepath = basepath;
4053 this.config = config;
4063 this.exclude = [].concat(this.config.exclude);
4073 this.files = this.config.files;
4083 _ref = this.config.src_folders;
4093 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
4103 folder = _ref[_i];
4113 result = fsu.find(folder.path, /.coffee$/m);
4123 fpath = folder.path;
4133 falias = folder.alias;
4143 for (_j = 0, _len1 = result.length; _j < _len1; _j++) {
4159 file = result[_j];
4169 include = true;
4179 _ref1 = this.exclude;
4189 for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
4190 item = _ref1[_k];
4200 include &= !(new RegExp(item).test(file));
421 }
4229 if (include) {
4239 s = new Script(this, fpath, file, falias);
4249 this.files.push(s);
425 }
426 }
427 }
428 }
429
4301 Builder.prototype.build = function(header_code, footer_code) {
4313 var contents, namespaces, options, vendors;
4323 if (header_code == null) {
4330 header_code = "";
434 }
4353 if (footer_code == null) {
4360 footer_code = "";
437 }
4383 namespaces = this._build_namespaces();
4393 vendors = this._merge_vendors();
4403 contents = [];
4413 if (this.config.packaging) {
4423 contents.push(namespaces);
443 }
4443 if (header_code !== "") {
4450 contents.push(header_code);
446 }
4473 contents.push(this._compile());
4483 if (header_code !== "") {
4490 contents.push(footer_code);
450 }
4513 contents = contents.join('\n');
4523 if (this.config.minify !== false) {
4532 if (this.config.minify === true) {
4540 options = {};
455 } else {
4562 options = this.config.minify;
457 }
4582 options.fromString = true;
4592 contents = uglify.minify(contents, options).code;
460 }
4613 if (this.config.callback != null) {
4621 contents = this.config.callback.apply(this, [contents, this.config.minify !== false]);
463 }
4643 if (vendors !== "") {
4653 contents = vendors + '\n' + contents;
466 }
4673 return fs.writeFileSync(this.config.release, contents);
468 };
469
470 /*
471 @return {String}
472 */
473
474
4751 Builder.prototype._merge_vendors = function() {
4763 var buffer, vendor, _i, _len, _ref;
4773 buffer = [];
4783 _ref = this.config.vendors;
4793 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
4803 vendor = _ref[_i];
4813 if (fs.existsSync(vendor)) {
4823 buffer.push(fs.readFileSync(vendor, 'utf-8'));
483 } else {
4840 warn("Vendor not found at ".white + vendor.yellow.bold);
485 }
486 }
4873 return buffer.join("\n");
488 };
489
490 /*
491 Creates a NS holder for all folders
492 */
493
494
4951 Builder.prototype._build_namespaces = function() {
4963 var buffer, folder, name, scope, t, tree, _i, _len, _ref;
4973 tree = {};
4983 _ref = this.config.src_folders;
4993 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
5003 folder = _ref[_i];
5013 if (folder.alias != null) {
5023 t = (tree[folder.alias] = {});
503 }
5043 this._build_ns_tree(t || tree, folder.path);
505 }
5063 buffer = "";
5073 for (name in tree) {
5083 scope = tree[name];
5093 buffer += "var " + name + " = ";
5103 if (this.config.expose != null) {
5110 buffer += "" + this.config.expose + "." + name + " = ";
512 }
5133 buffer += (JSON.stringify(scope, null, '')).replace(/\"/g, "'");
5143 buffer += ";\n";
515 }
5163 return buffer;
517 };
518
519 /*
520 Walk some folderpath and lists all its subfolders
521 */
522
523
5241 Builder.prototype._build_ns_tree = function(tree, folderpath) {
5256 var file, include, item, _i, _j, _len, _len1, _ref, _ref1, _results;
5266 if (!fs.lstatSync(folderpath).isDirectory()) {
5270 return;
528 }
5296 _ref = fsu.ls(folderpath);
5306 _results = [];
5316 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
53218 file = _ref[_i];
53318 if (!fs.lstatSync(file).isDirectory()) {
53415 continue;
535 }
5363 include = true;
5373 _ref1 = this.exclude;
5383 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
5390 item = _ref1[_j];
5400 include &= !(new RegExp(item).test(file));
541 }
5423 if (include) {
5433 _results.push(this._build_ns_tree((tree[file.match(/[^\/\\]+$/m)] = {}), file));
544 } else {
5450 _results.push(void 0);
546 }
547 }
5486 return _results;
549 };
550
551 /*
552 @return {String}
553 */
554
555
5561 Builder.prototype._compile = function() {
5573 var err, file, msg, output, _i, _j, _len, _len1, _ref, _ref1;
5583 _ref = this.files;
5593 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
5609 file = _ref[_i];
5619 try {
5629 cs.compile(file.raw);
563 } catch (_error) {
5640 err = _error;
5650 msg = err.message.replace('"', '\\"');
5660 msg = ("" + msg.white + " at file: ") + ("" + file.filepath).bold.red;
5670 error(msg);
5680 return null;
569 }
570 }
5713 _ref1 = this.files;
5723 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
5739 file = _ref1[_j];
5749 file.expand_dependencies();
575 }
5763 this._reorder();
5773 output = ((function() {
5783 var _k, _len2, _ref2, _results;
5793 _ref2 = this.files;
5803 _results = [];
5813 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
5829 file = _ref2[_k];
5839 _results.push(file.raw);
584 }
5853 return _results;
586 }).call(this)).join("\n");
5873 return output = cs.compile(output, {
588 bare: this.config.bare
589 });
590 };
591
592 /*
593 @param {Boolean} cycling
594 */
595
596
5971 Builder.prototype._reorder = function(cycling) {
5986 var bc, dependency, dependency_index, file, file_index, filepath, found, i, index, not_found, _i, _j, _len, _len1, _ref, _ref1, _results;
5996 if (cycling == null) {
6003 cycling = false;
601 }
6026 if (cycling === false) {
6033 this.missing = {};
604 }
6056 _ref = this.files;
6066 _results = [];
6076 for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
60818 file = _ref[i];
60918 if (!file.dependencies.length && !file.baseclasses.length) {
6103 continue;
611 }
61215 _ref1 = file.dependencies;
61315 for (index = _j = 0, _len1 = _ref1.length; _j < _len1; index = ++_j) {
61421 filepath = _ref1[index];
61521 dependency = ArrayUtil.find(this.files, filepath, "filepath");
61621 if (dependency != null) {
61721 dependency_index = dependency.index;
618 }
61921 if (dependency_index < i && (dependency != null)) {
62018 continue;
621 }
6223 if (dependency != null) {
6233 if (ArrayUtil.has(dependency.item.dependencies, file.filepath)) {
6240 file.dependencies.splice(index, 1);
6250 warn("Circular dependency found between ".yellow + filepath.grey.bold + " and ".yellow + file.filepath.grey.bold);
6260 continue;
627 } else {
6283 this.files.splice(index, 0, dependency.item);
6293 this.files.splice(dependency.index + 1, 1);
6303 this._reorder(true);
6313 break;
632 }
6330 } else if (this.missing[filepath] !== true) {
6340 this.missing[filepath] = true;
6350 file.dependencies.push(filepath);
6360 file.dependencies.splice(index, 1);
6370 warn("" + 'Dependency'.yellow + " " + filepath.bold.grey + " " + 'not found for file'.yellow + " " + file.filepath.grey.bold);
638 }
639 }
64015 file_index = ArrayUtil.find(this.files, file.filepath, "filepath");
64115 file_index = file_index.index;
64215 _results.push((function() {
64315 var _k, _len2, _ref2, _results1;
64415 _ref2 = file.baseclasses;
64515 _results1 = [];
64615 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
6470 bc = _ref2[_k];
6480 found = ArrayUtil.find(this.files, bc, "classname");
6490 not_found = (found === null) || (found.index > file_index);
6500 if (not_found && !this.missing[bc]) {
6510 this.missing[bc] = true;
6520 _results1.push(warn("Base class ".yellow + ("" + bc + " ").bold.grey + "not found for class ".yellow + ("" + file.classname + " ").bold.grey + "in file ".yellow + file.filepath.bold.grey));
653 } else {
6540 _results1.push(void 0);
655 }
656 }
65715 return _results1;
658 }).call(this));
659 }
6606 return _results;
661 };
662
6631 return Builder;
664
665 })();
666
6671 module.exports = Toaster = (function() {
6681 var path;
669
6701 path = require("path");
671
672 /*
673 @var {Cli}
674 */
675
676
6771 Toaster.prototype.options = null;
678
679 /*
680 @var {Object} before filter container
681 */
682
683
6841 Toaster.prototype.before_build = null;
685
6861 function Toaster(basedir, options) {
6873 this.toast = new Toast(path.resolve(basedir), options);
688 }
689
6901 Toaster.prototype.build = function(header_code, footer_code) {
6913 var builder, _i, _len, _ref, _results;
6923 if (header_code == null) {
6933 header_code = "";
694 }
6953 if (footer_code == null) {
6963 footer_code = "";
697 }
6983 _ref = this.toast.builders;
6993 _results = [];
7003 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
7013 builder = _ref[_i];
7023 _results.push(builder.build(header_code, footer_code));
703 }
7043 return _results;
705 };
706
7071 return Toaster;
708
709 })();
710
7111 log = function(msg) {
7120 console.log(msg);
7130 return msg;
714 };
715
7161 error = function(msg) {
7170 msg = log("ERROR ".bold.red + msg);
7180 return msg;
719 };
720
7211 warn = function(msg) {
7220 msg = log("WARNING ".bold.yellow + msg);
7230 return msg;
724 };
725
726}).call(this);
727
\ No newline at end of file