grunt.registerMultiTask('snockets', 'Building js files with snockets.js.', function() { // It doesn't run with empty src and dest parameters. if (typeof this.data.src === 'undefined' || typeof this.data.dest === 'undefined') { grunt.log.error('Missing Options: src and dest options necessary'); return false; } var minify = (this.data.minify === false ? false : true); if (fs.existsSync(path.resolve(this.data.src))) { try { js = snockets.getConcatenation(this.data.src, {async: false, minify: minify}); if (this.data.banner) js = this.data.banner + '\n' + js; grunt.file.write(path.resolve(this.data.dest)); fs.writeFileSync(path.resolve(this.data.dest), js); grunt.log.write(this.data.src + ' snocket to ' + this.data.dest + '\n'); return true; } catch (e) { grunt.log.error(e); return false; } } else { grunt.log.error('Missing File: ' + this.data.src); return false; } });
files.forEach(function(file){ try { var helper = new Helper(file) var compiled_js = snockets.getConcatenation(helper.file_path, { async: false }); helper.write(compiled_js) } catch (err) { error = err; } });
grunt.util.async.forEach(js, function (fn, callback) { snock.getConcatenation(fn, {minify: options.minify}, function (err, js) { if (err) { grunt.fail.fatal(err); } var combinedFile = outputFilename(fn, options); var javascript = headerFooter(js, options); grunt.file.write(combinedFile, javascript); callback(null); }); }, function(err) {
".coffee": function(srcPath, code, callback) { callback(null, snockets.getConcatenation(srcPath, { async: false, minify: process.env.NODE_ENV == "production" })); },