feat: auto clean client cache when SHOW_UPCOMING_CHANGES value changes (#43747)
* feat: auto clean client cache on env var change Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
const { spawn } = require('child_process');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
@ -101,6 +102,22 @@ if (FREECODECAMP_NODE_ENV !== 'development') {
|
|||||||
} else {
|
} else {
|
||||||
checkClientLocale();
|
checkClientLocale();
|
||||||
checkCurriculumLocale();
|
checkCurriculumLocale();
|
||||||
|
if (fs.existsSync(`${globalConfigPath}/env.json`)) {
|
||||||
|
const { showUpcomingChanges } = require(`${globalConfigPath}/env.json`);
|
||||||
|
if (env['showUpcomingChanges'] !== showUpcomingChanges) {
|
||||||
|
console.log(
|
||||||
|
'SHOW_UPCOMING_CHANGES value has changed, cleaning client cache.'
|
||||||
|
);
|
||||||
|
const child = spawn('npm', ['run', 'clean:client']);
|
||||||
|
child.stdout.setEncoding('utf8');
|
||||||
|
child.stdout.on('data', function (data) {
|
||||||
|
console.log(data);
|
||||||
|
});
|
||||||
|
child.on('error', err => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFileSync(`${globalConfigPath}/env.json`, JSON.stringify(env));
|
fs.writeFileSync(`${globalConfigPath}/env.json`, JSON.stringify(env));
|
||||||
|
Reference in New Issue
Block a user