Created
June 29, 2015 01:25
-
-
Save cdaringe/9876a24d71872ca45e0a to your computer and use it in GitHub Desktop.
grunt npm dedupe
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
var spawnSync = require('spawn-sync'); | |
var NODE_ENV = process.env.NODE_ENV; | |
var production = (NODE_ENV === 'production'); | |
/** | |
* `npm dedupe` in cwd | |
* @return {undefined} | |
*/ | |
var dedupe = function() { | |
var result; | |
result = spawnSync('npm', ['dedupe']); // 3rd arg, {cwd: ...} | |
process.stdout.write(result.stdout); | |
process.stderr.write(result.stderr); | |
if (result.status !== 0) { | |
process.exit(result.status); | |
} | |
}; | |
module.exports = function(grunt) { | |
grunt.registerTask('dedupe', 'dedupe', function() { | |
if (!development) { | |
dedupe(); | |
} else { | |
console.warn("notice: your browser dir will not be `npm dedupe`d in modes !== 'production'"); | |
} | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use before browserifying or webpacking prd code, pre npm3.0 (which promises ultra de-duping greatness!)