in packages/just-scripts/src/tasks/copyTask.ts [43:70]
function helper(srcPath: string, basePath = '') {
basePath = basePath || getBasePath(srcPath);
const matches = glob.sync(srcPath);
matches.forEach(matchedPath => {
if (fse.existsSync(matchedPath)) {
const stat = fse.statSync(matchedPath);
if (stat.isDirectory()) {
return helper(path.join(matchedPath, '**/*'), basePath);
}
}
const relativePath = path.relative(basePath, matchedPath);
copyTasks.push(cb => {
const readStream = fse.createReadStream(matchedPath);
const destPath = path.join(dest!, relativePath);
if (!fse.existsSync(path.dirname(destPath))) {
fse.mkdirpSync(path.dirname(destPath));
}
readStream.pipe(fse.createWriteStream(destPath));
readStream.on('error', err => cb(err));
readStream.on('end', cb);
});
});
}