@obliczeniowo/elementary
Version:
Library made in Angular version 20
40 lines (35 loc) • 960 B
JavaScript
const fs = require('fs');
const path = require('path');
const exclude = ['scripts'];
/**
* Look ma, it's cp -R.
* @param {string} src The path to the thing to copy.
* @param {string} dest The path to the new copy.
*/
function copyAssets(src, dest, copy = false) {
const exists = fs.existsSync(src);
const stats = exists && fs.statSync(src);
const isDirectory = exists && stats.isDirectory();
if (isDirectory) {
if (copy) {
try {
fs.mkdirSync(dest);
} catch (e) {}
}
fs.readdirSync(src).forEach(function (childItemName) {
if (!exclude.includes(childItemName)) {
copyAssets(
path.join(src, childItemName),
path.join(dest, childItemName),
true
);
}
});
} else {
try {
fs.copyFileSync(src, dest);
} catch (e) {}
}
}
const destination = process.argv.slice(2)[0];
copyAssets('node_modules/@obliczeniowo/elementary/assets', destination);