feat(packaging): automatically copy LICENSE to dist folders

This commit is contained in:
Yegor Jbanov
2015-02-09 14:02:11 -08:00
parent 583de5be42
commit 320c089dcc
2 changed files with 54 additions and 2 deletions

26
tools/build/multicopy.js Normal file
View File

@ -0,0 +1,26 @@
/**
* A utility that allows copying one file to multiple directories, such
* as the LICENSE file.
*/
var path = require('path');
var fs = require('fs');
module.exports = function(gulp, plugins, config) {
return function() {
var content = fs.readFileSync(config.src);
getSubdirs(config.dest).forEach(function(subDir) {
var destFile = path.join(config.dest, subDir, path.basename(config.src));
fs.writeFileSync(destFile, content);
});
};
};
function getSubdirs(rootDir) {
return fs.readdirSync(rootDir).filter(function(file) {
if (file[0] === '.') {
return false;
}
var dirPath = path.join(rootDir, file);
return fs.statSync(dirPath).isDirectory();
});
}