mirror of
https://github.com/wled/WLED.git
synced 2025-07-23 10:46:33 +00:00
Rebuild if a cdata.js has been modified
This commit is contained in:
parent
90d5b77d74
commit
5080059143
@ -83,11 +83,14 @@ describe('General functionality', () => {
|
|||||||
before(() => {
|
before(() => {
|
||||||
process.env.NODE_ENV = 'production';
|
process.env.NODE_ENV = 'production';
|
||||||
fs.cpSync("wled00/data", "wled00Backup", { recursive: true });
|
fs.cpSync("wled00/data", "wled00Backup", { recursive: true });
|
||||||
|
fs.cpSync("tools/cdata.js", "cdata.bak.js");
|
||||||
});
|
});
|
||||||
after(() => {
|
after(() => {
|
||||||
// Restore backup
|
// Restore backup
|
||||||
fs.rmSync("wled00/data", { recursive: true });
|
fs.rmSync("wled00/data", { recursive: true });
|
||||||
fs.renameSync("wled00Backup", "wled00/data");
|
fs.renameSync("wled00Backup", "wled00/data");
|
||||||
|
fs.rmSync("tools/cdata.js");
|
||||||
|
fs.renameSync("cdata.bak.js", "tools/cdata.js");
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Script', () => {
|
describe('Script', () => {
|
||||||
@ -190,5 +193,24 @@ describe('General functionality', () => {
|
|||||||
const currentTime = Date.now();
|
const currentTime = Date.now();
|
||||||
assert(currentTime - modifiedTime < 500, 'html_ui.h was not modified');
|
assert(currentTime - modifiedTime < 500, 'html_ui.h was not modified');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should rebuild if a cdata.js has been modified', async () => {
|
||||||
|
// run script cdata.js and wait for it to finish
|
||||||
|
await execPromise('node tools/cdata.js');
|
||||||
|
|
||||||
|
// modify index.htm
|
||||||
|
fs.appendFileSync('tools/cdata.js', ' ');
|
||||||
|
// delay for 1 second to ensure the modified time is different
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
|
||||||
|
// run script cdata.js and wait for it to finish
|
||||||
|
await execPromise('node tools/cdata.js');
|
||||||
|
|
||||||
|
// check if html_ui.h was modified
|
||||||
|
const stats = fs.statSync(path.join(folderPath, 'html_ui.h'));
|
||||||
|
const modifiedTime = stats.mtimeMs;
|
||||||
|
const currentTime = Date.now();
|
||||||
|
assert(currentTime - modifiedTime < 500, 'html_ui.h was not modified');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -227,7 +227,7 @@ function isAlreadyBuilt(folderPath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return !isAnyFileInFolderNewerThan(folderPath, lastBuildTime);
|
return !isAnyFileInFolderNewerThan(folderPath, lastBuildTime) && !isFileNewerThan("tools/cdata.js", lastBuildTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't run this script if we're in a test environment
|
// Don't run this script if we're in a test environment
|
||||||
|
Loading…
x
Reference in New Issue
Block a user