Skip to content

Commit

Permalink
fix: watch plugin-namespaced files
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeRomaa committed Jul 10, 2023
1 parent 992c777 commit 964939c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@synaptic-simulations/mach",
"version": "1.0.0",
"version": "1.0.1",
"description": "The last MSFS instrument bundler you'll ever need.",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
9 changes: 7 additions & 2 deletions src/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ export async function buildInstrument(config: MachConfig, instrument: Instrument
return result;
}

function resolveFilename(input: string): string {
return path.resolve(input.slice(input.indexOf(process.cwd())));
}

export async function watchInstrument(config: MachConfig, instrument: Instrument, logger: BuildLogger, module = false): Promise<BuildResultWithMeta> {
// Recursively watch included submodules
if (instrument.modules) {
Expand All @@ -121,7 +125,8 @@ export async function watchInstrument(config: MachConfig, instrument: Instrument
return result;
}

const watcher = chokidar.watch(Object.keys(result.metafile.inputs).map((input) => path.resolve(input)));
const builtFiles = Object.keys(result.metafile.inputs).map(resolveFilename);
const watcher = chokidar.watch(builtFiles);
watcher.on('change', async (filePath) => {
logger.changeDetected(filePath);

Expand All @@ -146,7 +151,7 @@ export async function watchInstrument(config: MachConfig, instrument: Instrument
logger.buildComplete(instrument.name, endTime - startTime, result);

const watchedFiles = watcher.getWatched();
const bundledFiles = Object.keys(result.metafile.inputs).map((input) => path.resolve(input));
const bundledFiles = Object.keys(result.metafile.inputs).map(resolveFilename);

// Watch files that have been added to the bundle
for (const file of bundledFiles) {
Expand Down

0 comments on commit 964939c

Please sign in to comment.