19 lines
507 B
JavaScript
19 lines
507 B
JavaScript
|
import fs from "fs";
|
||
|
import path from "path";
|
||
|
|
||
|
export function copyRecursively(file, destination) {
|
||
|
const target = path.join(destination, path.basename(file));
|
||
|
if (fs.statSync(file).isDirectory()) {
|
||
|
console.log('mkdir', target);
|
||
|
|
||
|
fs.mkdirSync(target, {recursive: true});
|
||
|
fs.readdirSync(file).forEach(f => {
|
||
|
copyRecursively(path.join(file, f), target);
|
||
|
});
|
||
|
} else {
|
||
|
console.log('> cp ', target);
|
||
|
|
||
|
fs.copyFileSync(file, target);
|
||
|
}
|
||
|
}
|