You can clone with HTTPS or SSH.
var uncomment = require('webProjectTools'); grunt.registerTask('uncomment4', 'Uncomment client JS files', function(){ var files = [ path.resolve(__dirname, 'client/js/bundle.min.js') ]; console.log('in gruntfile: ' + files); uncomment({ js: { src: files } }); });
// /path/to/webProjectBuilder/node_modules/webProjectTools/index.js var fse = require('fs-extra') , _ = require('lodash') , uncomment = require('uncommentify')({ all: true }) , cleanCss = require('clean-css'); var defaults = { js: { src: [] // paths relative to the calling script }, css: { src: [] // paths relative to the calling script } }; function errHandler(err, data) { if (err) return console.error('Failed with error: ' + err); // console.log('Source: ' + src); console.log('Success: ' + data); } // swapped src/dest naming here since matches the api function removeAndMove(src, dst, callback) { fse.remove(dst, function (err) { console.log('in module removeAndMove src: ' + src); console.log('in module removeAndMove dst: ' + dst); if (err) return callback(err); fse.move(src, dst, callback); }); } module.exports = function(opts){ var options = _.merge({}, defaults, opts); var src = options.js.src; console.log('in module outside foreach: ' + options.js.src); src.forEach(function (src) { console.log('in module foreach: ' + src); fse.createReadStream(src) .pipe(uncomment) .pipe(fse.createWriteStream(src + '.tmp')) .on('finish', function () { removeAndMove(src + '.tmp', src, errHandler); }); }); }
me@workstation:/path/to/webProjectBuilder$ grunt uncomment4 Running "uncomment4" task in gruntfile: /path/to/webProjectBuilder/client/js/bundle.min.js // this is the correct location in module outside foreach: /path/to/webProjectBuilder/client/js/bundle.min.js // this is the correct location in module foreach: /path/to/webProjectBuilder/client/js/bundle.min.js // this is the correct location Done, without errors. Execution Time (2014-09-30 11:52:49 UTC) loading tasks 1.4s ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 100% Total 1.4s