mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-03-21 17:25:10 -05:00
Clean mods/ and chat-plugins/ when building
Previously, if you deleted a file from `data/mods/`, it wouldn't also get deleted from `.data-dist/mods/`. This fixes that, and the corresponding issue in `server/chat-plugins/`. For reasons of performance and/or laziness, I've chosen to only clean those two directories, not all built directories.
This commit is contained in:
parent
636ebdd7f8
commit
4f32736bdd
2
build
2
build
|
|
@ -11,7 +11,7 @@ try {
|
|||
|
||||
var child_process = require('child_process');
|
||||
var fs = require('fs');
|
||||
var force = process.argv[2] === '--force';
|
||||
var force = ['--force', 'force', '--full', 'full'].includes(process.argv[2]);
|
||||
|
||||
process.chdir(__dirname);
|
||||
|
||||
|
|
|
|||
|
|
@ -21,12 +21,28 @@ function needsSucrase(source, dest, path = "") {
|
|||
if (!path.includes(".")) {
|
||||
// probably dir
|
||||
try {
|
||||
const files = fs.readdirSync(source + path);
|
||||
for (const file of files) {
|
||||
const sourceFiles = fs.readdirSync(source + path);
|
||||
for (const file of sourceFiles) {
|
||||
if (needsSucrase(source, dest, path + "/" + file)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (path.endsWith('/chat-plugins') || path.includes('/mods/')) {
|
||||
const destFiles = fs.readdirSync(dest + path);
|
||||
for (const file of destFiles) {
|
||||
if (file.endsWith('.js') && !sourceFiles.includes(file.slice(0, -2) + 'ts') && !sourceFiles.includes(file)) {
|
||||
fs.unlinkSync(dest + path + "/" + file);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (path.endsWith('/mods')) {
|
||||
const destFolders = fs.readdirSync(dest + path);
|
||||
for (const destFolder of destFolders) {
|
||||
if (!destFolder.includes('.') && !sourceFiles.includes(destFolder)) {
|
||||
fs.rmSync(dest + path + "/" + destFolder, {recursive: true});
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// not dir
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user