Created
May 11, 2020 13:26
-
-
Save cnoss/71c00c962a9784bb8523393f06f40026 to your computer and use it in GitHub Desktop.
Helper Script for npm scripts buildchain
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
const fs = require('fs'); | |
var finder = require('findit')('.'); | |
var path = require('path'); | |
var pattern = process.argv[2].replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + "$"; | |
finder.on('directory', function (dir, stat, stop) { | |
var base = path.basename(dir); | |
if (base === '.git' || base === 'node_modules') stop() | |
}); | |
finder.on('file', function (file, stat) { | |
if(file.match(pattern)){ | |
let source = file; | |
let target = source.replace(/^src/, "dist"); | |
fs.copyFile(source, target, function(){ | |
console.log(`copy ${source} -> ${target}`); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment