Skip to content

Commit 9c6bb68

Browse files
committed
Add yalc-files to the delete script
1 parent 103d275 commit 9c6bb68

2 files changed

Lines changed: 31 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"core:start": "npm --prefix ../paranext-core start",
3333
"core:stop": "npm --prefix ../paranext-core stop",
3434
"core:reset": "npm run core:stop && node ./scripts/delete-temp-files.cjs --core --ext",
35-
"core:reinstall": "npm run core:reset && node ./scripts/delete-temp-files.cjs --npm && npm run core:update && npm i",
35+
"core:reinstall": "npm run core:stop && node ./scripts/delete-temp-files.cjs --all && npm run core:update && npm i",
3636
"core:install": "npm --prefix ../paranext-core install",
3737
"core:pull": "git -C ../paranext-core pull --ff-only",
3838
"core:update": "npm run core:pull && npm run core:install"

scripts/delete-temp-files.cjs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,39 @@ const path = require('path');
99
*
1010
* - The `Electron` cache folder, which affect any other Electron apps
1111
* - `paranext-core/dev-appdata/`, which includes `installed-extensions/`
12+
*
13+
* Warning: The `--yalc` flag deletion includes:
14+
*
15+
* - `paranext-core/dev-packages/`, which makes the core re-install last minutes longer
1216
*/
1317

1418
// Check command-line arguments
1519

20+
const hasAllFlag = process.argv.includes('--all');
1621
const hasCoreFlag = process.argv.includes('--core');
1722
const hasExtFlag = process.argv.includes('--ext');
1823
const hasNpmFlag = process.argv.includes('--npm');
24+
const hasYalcFlag = process.argv.includes('--yalc');
1925

20-
if (!hasCoreFlag && !hasExtFlag && !hasNpmFlag) {
21-
console.error('Usage: node delete-temp-files.cjs [--core] [--ext] [--npm]');
26+
if (!hasAllFlag && !hasCoreFlag && !hasExtFlag && !hasNpmFlag && !hasYalcFlag) {
27+
console.error('Usage: node delete-temp-files.cjs [--all] [--core] [--ext] [--npm] [--yalc]');
2228
console.error(' --core Delete Electron and core caches (Electron, dev-appdata)');
2329
console.error(' --ext Delete extension directories (coverage, dist, src/temp-build)');
2430
console.error(' --npm Delete both node_modules and extension package-lock.json');
31+
console.error(' --yalc Delete core yalc-related files');
32+
console.error(' --all Delete all of the above');
2533
process.exit(1);
2634
}
2735

36+
const shouldDeleteCore = hasAllFlag || hasCoreFlag;
37+
const shouldDeleteExt = hasAllFlag || hasExtFlag;
38+
const shouldDeleteNpm = hasAllFlag || hasNpmFlag;
39+
const shouldDeleteYalc = hasAllFlag || hasYalcFlag;
40+
2841
// Define directory lists
2942

3043
let electronParent = '';
31-
if (hasCoreFlag) {
44+
if (shouldDeleteCore) {
3245
/* eslint-disable no-nested-ternary */
3346
electronParent =
3447
process.platform === 'win32'
@@ -64,6 +77,12 @@ const NPM_PATHS = [
6477
path.join(__dirname, '..', 'package-lock.json'),
6578
];
6679

80+
const YALC_PATHS = [
81+
path.join(__dirname, '..', '..', 'paranext-core', '.yalc'),
82+
path.join(__dirname, '..', '..', 'paranext-core', 'dev-packages'),
83+
path.join(__dirname, '..', '..', 'paranext-core', 'yalc.lock'),
84+
];
85+
6786
/**
6887
* Delete a path if it exists
6988
*
@@ -90,21 +109,26 @@ function deletePath(pathToDelete) {
90109
// Delete paths based on command-line flags
91110

92111
try {
93-
if (hasCoreFlag) {
112+
if (shouldDeleteCore) {
94113
console.log('Deleting core cache directories...');
95114
CORE_DIRS.forEach(deletePath);
96115
}
97116

98-
if (hasExtFlag) {
117+
if (shouldDeleteExt) {
99118
console.log('Deleting extension directories...');
100119
EXT_DIRS.forEach(deletePath);
101120
}
102121

103-
if (hasNpmFlag) {
122+
if (shouldDeleteNpm) {
104123
console.log('Deleting node_modules and package-lock.json...');
105124
NPM_PATHS.forEach(deletePath);
106125
}
107126

127+
if (shouldDeleteYalc) {
128+
console.log('Deleting core yalc-related files...');
129+
YALC_PATHS.forEach(deletePath);
130+
}
131+
108132
console.log('Complete!');
109133
process.exit(0);
110134
} catch (error) {

0 commit comments

Comments
 (0)