Skip to content

Instantly share code, notes, and snippets.

@cnoss
Created May 11, 2020 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cnoss/71c00c962a9784bb8523393f06f40026 to your computer and use it in GitHub Desktop.
Save cnoss/71c00c962a9784bb8523393f06f40026 to your computer and use it in GitHub Desktop.
Helper Script for npm scripts buildchain
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