2021-11-20 15:30:02 +01:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
2021-05-27 15:26:19 +02:00
|
|
|
|
2021-11-20 15:30:02 +01:00
|
|
|
function copyRecursively(file, destination) {
|
2021-05-27 15:26:19 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2021-11-20 15:30:02 +01:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
copyRecursively,
|
|
|
|
};
|