From 7a5143e9c880e448c22c2acb67be97f1afcec4fd Mon Sep 17 00:00:00 2001 From: Tanimodori Date: Thu, 20 Oct 2022 11:22:47 +0800 Subject: [PATCH] fix: check both ts and js source now --- build/watch.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build/watch.js b/build/watch.js index 3669f34..11d6d9d 100644 --- a/build/watch.js +++ b/build/watch.js @@ -50,9 +50,12 @@ async function initTypeScript() { for (const distFile of distFiles) { // search existing *.js file in dist const relative = path.relative(dist, distFile); - const srcFile = path.resolve(src, relative).replace(/\.js$/, '.ts'); + const srcFile = path.resolve(src, relative); // if srcFile does not exist, delete distFile - if (!fs.existsSync(srcFile)) { + if ( + !fs.existsSync(srcFile) && + !fs.existsSync(srcFile.replace(/\.js$/, '.ts')) + ) { await fs.promises.unlink(distFile); console.log(`${normalize(relative)} deleted`); }