Created
December 6, 2016 11:20
-
-
Save rodebert/baeb293ecd1132d410e3a452750c99c9 to your computer and use it in GitHub Desktop.
Copy main soure from dependencies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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