mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
build(copy-dist): add initial cleanupNodeModules functionality
adapted from copy-trilium.sh
This commit is contained in:
parent
bee7793d32
commit
6260ea1532
@ -61,7 +61,30 @@ try {
|
||||
// TriliumNextTODO: for Docker this needs to run separately *after* build-stage
|
||||
console.log("Pruning npm packages...")
|
||||
execSync(`npm ci --omit=dev --prefix ${DEST_DIR}`);
|
||||
|
||||
cleanupNodeModules();
|
||||
|
||||
} catch(err) {
|
||||
console.error("Error during copy:", err)
|
||||
process.exit(1)
|
||||
}
|
||||
function cleanupNodeModules() {
|
||||
const nodeDir = fs.readdirSync(path.join(DEST_DIR, "./node_modules"), { recursive: true, withFileTypes: true });
|
||||
|
||||
const filterableDirs = new Set([
|
||||
"test",
|
||||
"docs",
|
||||
"demo",
|
||||
"example",
|
||||
]);
|
||||
|
||||
const filteredDirs = nodeDir
|
||||
.filter(el => el.isDirectory() && filterableDirs.has(el.name))
|
||||
.map(el => path.join(DEST_DIR, el.parentPath, el.name));
|
||||
|
||||
filteredDirs.forEach(dir => {
|
||||
fs.removeSync(dir);
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,6 @@ if [[ -d "$BUILD_DIR"/node_modules ]]; then
|
||||
'@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do
|
||||
[[ -e "$BUILD_DIR"/node_modules/"$d" ]] && rm -r "$BUILD_DIR"/node_modules/"$d"
|
||||
done
|
||||
|
||||
# delete all tests (there are often large images as test file for jimp etc.)
|
||||
for d in 'test' 'docs' 'demo' 'example'; do
|
||||
find "$BUILD_DIR"/node_modules -name "$d" -exec rm -rf {} +
|
||||
done
|
||||
fi
|
||||
|
||||
find $BUILD_DIR/libraries -name "*.map" -type f -delete
|
||||
|
Loading…
x
Reference in New Issue
Block a user