From eb95c214d47f4994241cd394c81f22a8d6b25c3b Mon Sep 17 00:00:00 2001 From: Zyie <24736175+Zyie@users.noreply.github.com> Date: Thu, 2 Mar 2023 13:51:18 +0000 Subject: [PATCH] fix watch command (#28) --- packages/core/src/Processor.ts | 17 ++++++++++++++++- packages/manifest/src/pixi.ts | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/core/src/Processor.ts b/packages/core/src/Processor.ts index 59568ff..659d8ad 100644 --- a/packages/core/src/Processor.ts +++ b/packages/core/src/Processor.ts @@ -7,7 +7,7 @@ import { SavableAssetCache } from './Cache'; import type { ReqAssetPackConfig } from './config'; import { Logger } from './logger/Logger'; import type { Plugin } from './Plugin'; -import { hasTag, replaceExt } from './utils'; +import { hasTag, path, replaceExt } from './utils'; interface SaveOptions { @@ -300,6 +300,21 @@ export class Processor if (SavableAssetCache.has(tree.path)) { + const asset = SavableAssetCache.get(tree.path); + + if (asset.transformData?.files.length > 0) + { + asset.transformData.files.forEach((file) => + { + file.paths.forEach((shortPath) => + { + const fullPath = path.join(this.config.output, shortPath); + + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + fs.existsSync(fullPath) && fs.removeSync(fullPath); + }); + }); + } SavableAssetCache.remove(tree.path); } } diff --git a/packages/manifest/src/pixi.ts b/packages/manifest/src/pixi.ts index 01a0d35..d778f27 100644 --- a/packages/manifest/src/pixi.ts +++ b/packages/manifest/src/pixi.ts @@ -96,6 +96,9 @@ function collect( options: PixiManifestOptions ) { + // an item may have been deleted, so we don't want to add it to the manifest! + if (tree.state === 'deleted') return; + const targetPath = getManifestName(tree.path, processor.config.entry) || 'default'; if (!bundles.has(targetPath))