changed watch callback

This commit is contained in:
2022-06-08 16:55:16 -05:00
parent 74904d1c0f
commit 78e9531e83
6 changed files with 33 additions and 22 deletions

View File

@@ -31,14 +31,14 @@ if (!(0, fs_1.existsSync)('package.json') || !(0, fs_1.lstatSync)('package.json'
let id = scriptMeta.length;
function postWatchUpdate(meta, error) {
scriptMeta[id] = { meta, error };
doErrorFile(path.error, error);
doErrorFile(path.error, (0, paths_1.DistPath)(name), error);
console.log('WATCH', name, meta.version);
(0, readmefile_1.updateReadmeFile)(scriptMeta);
}
let [meta, error] = await (0, build_1.default)(name, postWatchUpdate);
let [meta, error] = await (0, build_1.default)(name, CLIArgs.watch ? postWatchUpdate : false);
scriptMeta[id] = { meta, error };
console.log(name, meta.version);
doErrorFile(path.error, error);
doErrorFile(path.error, (0, paths_1.DistPath)(name), error);
}
}
(0, readmefile_1.updateReadmeFile)(scriptMeta);
@@ -46,9 +46,12 @@ if (!(0, fs_1.existsSync)('package.json') || !(0, fs_1.lstatSync)('package.json'
if (CLIArgs.watch)
console.log('Listening for Changes\n');
})();
function doErrorFile(pathError, error) {
function doErrorFile(pathError, pathOutFile, error) {
if (error !== null) {
(0, fs_1.writeFileSync)(pathError, `${new Date().toISOString()}\n\n${error}`);
if ((0, fs_1.existsSync)(pathOutFile)) {
(0, fs_1.unlinkSync)(pathOutFile);
}
}
else if ((0, fs_1.existsSync)(pathError)) {
(0, fs_1.unlinkSync)(pathError);