@travetto/manifest 3.0.0-rc.10 → 3.0.0-rc.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/manifest",
3
- "version": "3.0.0-rc.10",
3
+ "version": "3.0.0-rc.11",
4
4
  "description": "Manifest support",
5
5
  "keywords": [
6
6
  "path",
@@ -301,12 +301,12 @@ export class ManifestIndex {
301
301
  /**
302
302
  * Get local folders that represent the user's controlled input
303
303
  */
304
- getLocalInputFolders(): string[] {
305
- return this.getLocalModules()
306
- .flatMap(x =>
307
- (!this.manifest.monoRepo || x.sourcePath !== this.manifest.workspacePath) ?
308
- [x.sourcePath] : [...Object.keys(x.files)].filter(y => !y.startsWith('$')).map(y => path.resolve(x.sourcePath, y))
309
- );
304
+ getLocalInputFolderMapping(): [folder: string, moduleSourceRoot: string][] {
305
+ return this.getLocalModules().flatMap(x =>
306
+ ((!this.manifest.monoRepo || x.sourcePath !== this.manifest.workspacePath) ?
307
+ [x.sourcePath] : [...Object.keys(x.files)].filter(y => !y.startsWith('$')).map(y => path.resolve(x.sourcePath, y))
308
+ ).map(f => [f, path.resolve(x.sourceFolder)] as [string, string])
309
+ );
310
310
  }
311
311
 
312
312
  /**
package/src/watch.ts CHANGED
@@ -22,12 +22,15 @@ async function getWatcher(): Promise<typeof import('@parcel/watcher')> {
22
22
  * @param onEvent
23
23
  * @private
24
24
  */
25
- export async function watchFolders(folders: string[], onEvent: WatchEventListener, config: WatchConfig = {}): Promise<() => Promise<void>> {
25
+ export async function watchFolders(folders: string[] | [folder: string, targetFolder: string][], onEvent: WatchEventListener, config: WatchConfig = {}): Promise<() => Promise<void>> {
26
26
  const lib = await getWatcher();
27
27
  const createMissing = config.createMissing ?? false;
28
- const validFolders = new Set(folders);
28
+ const validFolders = new Set(folders.map(x => typeof x === 'string' ? x : x[0]));
29
+
30
+ const subs = await Promise.all(folders.map(async value => {
31
+ const folder = typeof value === 'string' ? value : value[0];
32
+ const targetFolder = typeof value === 'string' ? value : value[1];
29
33
 
30
- const subs = await Promise.all(folders.map(async folder => {
31
34
  if (await fs.stat(folder).then(() => true, () => createMissing)) {
32
35
  await fs.mkdir(folder, { recursive: true });
33
36
  const ignore = (await fs.readdir(folder)).filter(x => x.startsWith('.') && x.length > 2);
@@ -38,7 +41,7 @@ export async function watchFolders(folders: string[], onEvent: WatchEventListene
38
41
  }
39
42
  const finalEv = { action: ev.type, file: ev.path };
40
43
  if (!config.filter || config.filter(finalEv)) {
41
- onEvent(finalEv, folder);
44
+ onEvent(finalEv, targetFolder);
42
45
  }
43
46
  }
44
47
  }, { ignore: [...ignore, ...config.ignore ?? []] });