Skip to content

Instantly share code, notes, and snippets.

@rodebert
Created December 6, 2016 11:20
Show Gist options
  • Save rodebert/baeb293ecd1132d410e3a452750c99c9 to your computer and use it in GitHub Desktop.
Save rodebert/baeb293ecd1132d410e3a452750c99c9 to your computer and use it in GitHub Desktop.
Copy main soure from dependencies
grunt.task.registerTask('copy-deps', 'Copy npm dependencies', function () {
var done = this.async();
var deps = Object.keys(pkg.dependencies);
var path = require('path');
var fs = require('fs');
if ( deps.length ) {
deps.forEach((dep) => {
var depDir = path.join(__dirname, 'node_modules', dep);
var depPkg = require(path.join(depDir, 'package.json'));
if ( depPkg.main ) {
fs.createReadStream( path.join(depDir, depPkg.main )).pipe(fs.createWriteStream(path.join(__dirname, 'src/js/vendor', depPkg.main.split('/').pop() )));
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment