Skip to content

Commit

Permalink
Use new util for watching
Browse files Browse the repository at this point in the history
  • Loading branch information
simonihmig committed Sep 10, 2024
1 parent 104e753 commit de5f6e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/ember-auto-import/ts/auto-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ import type { TransformOptions } from '@babel/core';
import { MARKER } from './analyzer-syntax';
import path from 'path';
import funnel from 'broccoli-funnel';
import makeDebug from 'debug';

const debugTree = buildDebugCallback('ember-auto-import');
const debugWatch = makeDebug('ember-auto-import:watch');

// This interface must be stable across all versions of ember-auto-import that
// speak the same leader-election protocol. So don't change this unless you know
Expand Down Expand Up @@ -244,6 +246,7 @@ function depsFor(allAppTree: Node, packages: Set<Package>) {
let watched = pkg.watchedDirectories;
if (watched) {
deps = deps.concat(watched.map((dir) => new WatchedDir(dir)));
debugWatch(`Adding watched directories: ${watched.join(', ')}`);
}
}
return deps;
Expand Down
9 changes: 6 additions & 3 deletions packages/ember-auto-import/ts/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { PluginItem, TransformOptions } from '@babel/core';
import { MacrosConfig } from '@embroider/macros/src/node';
import minimatch from 'minimatch';
import { stripQuery } from './util';
import { getWatchedDirectories } from './watch-utils';

// from child addon instance to their parent package
const parentCache: WeakMap<AddonInstance, Package> = new WeakMap();
Expand Down Expand Up @@ -514,13 +515,15 @@ export default class Package {
for (let name of names) {
let path = resolvePackagePath(name, cursor);
if (!path) {
return undefined;
return [];
}
cursor = dirname(path);
}
return cursor;
return getWatchedDirectories(cursor).map((relativeDir) =>
join(cursor, relativeDir)
);
})
.filter(Boolean) as string[];
.flat();
}
}

Expand Down

0 comments on commit de5f6e5

Please sign in to comment.