swaf/scripts/prepare-sources.js

25 lines
606 B
JavaScript
Raw Normal View History

import fs from "fs";
import path from "path";
import {copyRecursively} from "./_functions.js";
2021-04-27 15:44:20 +02:00
// These folders must exist for nodemon not to loop indefinitely.
[
'public',
'dist',
'intermediates',
'intermediates/assets',
].forEach(dir => {
if (!fs.existsSync(dir)) fs.mkdirSync(dir);
});
// Symlink to build/common
const symlink = path.resolve('intermediates/common');
if (!fs.existsSync(symlink)) {
fs.symlinkSync(path.resolve('dist/common'), symlink);
}
// Copy all source files
fs.readdirSync('src').forEach(file => {
copyRecursively(path.join('src', file), 'dist');
});