@ms-cloudpack/file-watcher 0.4.0 → 0.4.2

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.
@@ -4,6 +4,7 @@ import { BaseWatcher } from './BaseWatcher.js';
4
4
  * Watch for changes using chokidar in the current process.
5
5
  */
6
6
  export declare class ParcelWatcher extends BaseWatcher {
7
+ private readonly _backend;
7
8
  protected _watch(options: WatchOptionsWithId, onChange: WatchChangeCallback): Promise<UnwatchCallback>;
8
9
  }
9
10
  //# sourceMappingURL=ParcelWatcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ParcelWatcher.d.ts","sourceRoot":"","sources":["../src/ParcelWatcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;cAK5B,MAAM,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;CAsB7G"}
1
+ {"version":3,"file":"ParcelWatcher.d.ts","sourceRoot":"","sources":["../src/ParcelWatcher.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;GAEG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAK5C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAC2E;cAMpF,MAAM,CAAC,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,mBAAmB,GAAG,OAAO,CAAC,eAAe,CAAC;CAsB7G"}
@@ -6,6 +6,11 @@ import { separateGlobs } from './separateGlobs.js';
6
6
  * Watch for changes using chokidar in the current process.
7
7
  */
8
8
  export class ParcelWatcher extends BaseWatcher {
9
+ // Using watchman in codespaces leads to the following error:
10
+ // watchman::RootResolveError: failed to resolve root: unable to resolve root
11
+ // So we use the default backend based on the platform, based on:
12
+ // https://github.com/microsoft/vscode/blob/b482c0e99d5c424d85d6bd5eabccafca430e8072/src/vs/platform/files/node/watcher/parcel/parcelWatcher.ts#L158
13
+ _backend = process.platform === 'win32' ? 'windows' : process.platform === 'linux' ? 'inotify' : 'fs-events';
9
14
  // TODO: Ideally if this is called multiple times with a different ID but the same root path and
10
15
  // same watch paths, a single watcher should be created and shared. But this involves a
11
16
  // lot of extra tracking logic and isn't essential until SSR is actually being used in an app.
@@ -21,7 +26,7 @@ export class ParcelWatcher extends BaseWatcher {
21
26
  const uniquePaths = new Set(events.map((event) => event.path));
22
27
  onChange([...uniquePaths]);
23
28
  }
24
- }, { ignore: negativeGlobs });
29
+ }, { ignore: negativeGlobs, backend: this._backend });
25
30
  return async () => {
26
31
  await watcher?.unsubscribe();
27
32
  watcher = undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"ParcelWatcher.js","sourceRoot":"","sources":["../src/ParcelWatcher.ts"],"names":[],"mappings":"AAAA,OAAO,MAAkC,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,gGAAgG;IAChG,uFAAuF;IACvF,8FAA8F;IAC9F,+DAA+D;IACrD,KAAK,CAAC,MAAM,CAAC,OAA2B,EAAE,QAA6B;QAC/E,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,GAAG,gBAAgB,EAAE,GAAG,OAAO,CAAC;QAClE,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;QAEpD,IAAI,OAAO,GAAkC,MAAM,MAAM,CAAC,SAAS,CACjE,QAAQ,EACR,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACd,IAAI,GAAG,EAAE,CAAC;gBACR,OAAO,CAAC,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;YAChD,CAAC;iBAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBACzB,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC/D,QAAQ,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC,EACD,EAAE,MAAM,EAAE,aAAa,EAAE,CAC1B,CAAC;QAEF,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,OAAO,EAAE,WAAW,EAAE,CAAC;YAC7B,OAAO,GAAG,SAAS,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import parcel, { type AsyncSubscription } from '@parcel/watcher';\nimport type { UnwatchCallback, WatchChangeCallback, WatchOptionsWithId } from './types/Watcher.js';\nimport { BaseWatcher } from './BaseWatcher.js';\nimport { sourceFilesGlobs } from '@ms-cloudpack/path-utilities';\nimport { separateGlobs } from './separateGlobs.js';\n\n/**\n * Watch for changes using chokidar in the current process.\n */\nexport class ParcelWatcher extends BaseWatcher {\n // TODO: Ideally if this is called multiple times with a different ID but the same root path and\n // same watch paths, a single watcher should be created and shared. But this involves a\n // lot of extra tracking logic and isn't essential until SSR is actually being used in an app.\n // Tracking: https://github.com/microsoft/cloudpack/issues/3046\n protected async _watch(options: WatchOptionsWithId, onChange: WatchChangeCallback): Promise<UnwatchCallback> {\n const { path: rootPath, watchPaths = sourceFilesGlobs } = options;\n const { negativeGlobs } = separateGlobs(watchPaths);\n\n let watcher: AsyncSubscription | undefined = await parcel.subscribe(\n rootPath,\n (err, events) => {\n if (err) {\n console.error(`Error watching files: ${err}`);\n } else if (events.length) {\n const uniquePaths = new Set(events.map((event) => event.path));\n onChange([...uniquePaths]);\n }\n },\n { ignore: negativeGlobs },\n );\n\n return async () => {\n await watcher?.unsubscribe();\n watcher = undefined;\n };\n }\n}\n"]}
1
+ {"version":3,"file":"ParcelWatcher.js","sourceRoot":"","sources":["../src/ParcelWatcher.ts"],"names":[],"mappings":"AAAA,OAAO,MAAkC,MAAM,iBAAiB,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,WAAW;IAC5C,6DAA6D;IAC7D,6EAA6E;IAC7E,iEAAiE;IACjE,oJAAoJ;IACnI,QAAQ,GACvB,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC;IAEpG,gGAAgG;IAChG,uFAAuF;IACvF,8FAA8F;IAC9F,+DAA+D;IACrD,KAAK,CAAC,MAAM,CAAC,OAA2B,EAAE,QAA6B;QAC/E,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,GAAG,gBAAgB,EAAE,GAAG,OAAO,CAAC;QAClE,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;QAEpD,IAAI,OAAO,GAAkC,MAAM,MAAM,CAAC,SAAS,CACjE,QAAQ,EACR,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACd,IAAI,GAAG,EAAE,CAAC;gBACR,OAAO,CAAC,KAAK,CAAC,yBAAyB,GAAG,EAAE,CAAC,CAAC;YAChD,CAAC;iBAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;gBACzB,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC/D,QAAQ,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;YAC7B,CAAC;QACH,CAAC,EACD,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,CAClD,CAAC;QAEF,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,OAAO,EAAE,WAAW,EAAE,CAAC;YAC7B,OAAO,GAAG,SAAS,CAAC;QACtB,CAAC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import parcel, { type AsyncSubscription } from '@parcel/watcher';\nimport type { UnwatchCallback, WatchChangeCallback, WatchOptionsWithId } from './types/Watcher.js';\nimport { BaseWatcher } from './BaseWatcher.js';\nimport { sourceFilesGlobs } from '@ms-cloudpack/path-utilities';\nimport { separateGlobs } from './separateGlobs.js';\n\n/**\n * Watch for changes using chokidar in the current process.\n */\nexport class ParcelWatcher extends BaseWatcher {\n // Using watchman in codespaces leads to the following error:\n // watchman::RootResolveError: failed to resolve root: unable to resolve root\n // So we use the default backend based on the platform, based on:\n // https://github.com/microsoft/vscode/blob/b482c0e99d5c424d85d6bd5eabccafca430e8072/src/vs/platform/files/node/watcher/parcel/parcelWatcher.ts#L158\n private readonly _backend =\n process.platform === 'win32' ? 'windows' : process.platform === 'linux' ? 'inotify' : 'fs-events';\n\n // TODO: Ideally if this is called multiple times with a different ID but the same root path and\n // same watch paths, a single watcher should be created and shared. But this involves a\n // lot of extra tracking logic and isn't essential until SSR is actually being used in an app.\n // Tracking: https://github.com/microsoft/cloudpack/issues/3046\n protected async _watch(options: WatchOptionsWithId, onChange: WatchChangeCallback): Promise<UnwatchCallback> {\n const { path: rootPath, watchPaths = sourceFilesGlobs } = options;\n const { negativeGlobs } = separateGlobs(watchPaths);\n\n let watcher: AsyncSubscription | undefined = await parcel.subscribe(\n rootPath,\n (err, events) => {\n if (err) {\n console.error(`Error watching files: ${err}`);\n } else if (events.length) {\n const uniquePaths = new Set(events.map((event) => event.path));\n onChange([...uniquePaths]);\n }\n },\n { ignore: negativeGlobs, backend: this._backend },\n );\n\n return async () => {\n await watcher?.unsubscribe();\n watcher = undefined;\n };\n }\n}\n"]}
@@ -17,7 +17,7 @@ type ChangeMessage = Pick<WatchOptionsWithId, 'id'> & {
17
17
  };
18
18
  type ErrorMessage = {
19
19
  type: 'error';
20
- error: Error;
20
+ error: string;
21
21
  };
22
22
  /** Message from the child to the parent in `ForkWatcher` */
23
23
  export type ChildMessage = ChangeMessage | ErrorMessage;
@@ -1 +1 @@
1
- {"version":3,"file":"WatchMessages.d.ts","sourceRoot":"","sources":["../../src/types/WatchMessages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAErE,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;CACjC,CAAC;AAEF,KAAK,cAAc,GAAG,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,GAAG;IACrD,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,cAAc,GAAG,eAAe,CAAC;AAE5E,KAAK,aAAa,GAAG,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,GAAG;IACpD,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,YAAY,CAAC"}
1
+ {"version":3,"file":"WatchMessages.d.ts","sourceRoot":"","sources":["../../src/types/WatchMessages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAErE,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;CACjC,CAAC;AAEF,KAAK,cAAc,GAAG,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,GAAG;IACrD,IAAI,EAAE,SAAS,CAAC;CACjB,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,UAAU,CAAC;CAClB,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,cAAc,GAAG,eAAe,CAAC;AAE5E,KAAK,aAAa,GAAG,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,GAAG;IACpD,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"WatchMessages.js","sourceRoot":"","sources":["../../src/types/WatchMessages.ts"],"names":[],"mappings":"","sourcesContent":["import type { WatchOptions, WatchOptionsWithId } from './Watcher.js';\n\ntype WatchMessage = {\n type: 'watch';\n options: Required<WatchOptions>;\n};\n\ntype UnwatchMessage = Pick<WatchOptionsWithId, 'id'> & {\n type: 'unwatch';\n};\n\ntype ShutdownMessage = {\n type: 'shutdown';\n};\n\n/** Message from the parent to the child in `ForkWatcher` */\nexport type ParentMessage = WatchMessage | UnwatchMessage | ShutdownMessage;\n\ntype ChangeMessage = Pick<WatchOptionsWithId, 'id'> & {\n type: 'change';\n changedPaths: string[];\n};\n\ntype ErrorMessage = {\n type: 'error';\n error: Error;\n};\n\n/** Message from the child to the parent in `ForkWatcher` */\nexport type ChildMessage = ChangeMessage | ErrorMessage;\n"]}
1
+ {"version":3,"file":"WatchMessages.js","sourceRoot":"","sources":["../../src/types/WatchMessages.ts"],"names":[],"mappings":"","sourcesContent":["import type { WatchOptions, WatchOptionsWithId } from './Watcher.js';\n\ntype WatchMessage = {\n type: 'watch';\n options: Required<WatchOptions>;\n};\n\ntype UnwatchMessage = Pick<WatchOptionsWithId, 'id'> & {\n type: 'unwatch';\n};\n\ntype ShutdownMessage = {\n type: 'shutdown';\n};\n\n/** Message from the parent to the child in `ForkWatcher` */\nexport type ParentMessage = WatchMessage | UnwatchMessage | ShutdownMessage;\n\ntype ChangeMessage = Pick<WatchOptionsWithId, 'id'> & {\n type: 'change';\n changedPaths: string[];\n};\n\ntype ErrorMessage = {\n type: 'error';\n error: string;\n};\n\n/** Message from the child to the parent in `ForkWatcher` */\nexport type ChildMessage = ChangeMessage | ErrorMessage;\n"]}
@@ -25,7 +25,8 @@ function initializeWatcher() {
25
25
  }
26
26
  })().catch((error) => {
27
27
  try {
28
- sendMessage({ type: 'error', error: error });
28
+ const errorMessage = error instanceof Error ? error.message : String(error);
29
+ sendMessage({ type: 'error', error: errorMessage });
29
30
  }
30
31
  catch (sendError) {
31
32
  console.error('Failed to send error message:', sendError);
@@ -1 +1 @@
1
- {"version":3,"file":"watcherForkWrapper.js","sourceRoot":"","sources":["../src/watcherForkWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAInD;;GAEG;AACH,SAAS,iBAAiB;IACxB,0CAA0C;I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CAAC;AAED,yCAAyC;AACzC,SAAS,WAAW,CAAC,OAAqB;IACxC,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED,gDAAgD;AAChD,2EAA2E;AAC3E,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAE/B,iBAAiB,EAAE,CAAC","sourcesContent":["import { DefaultWatcher } from './DefaultWatcher.js';\nimport { ParcelWatcher } from './ParcelWatcher.js';\nimport type { Backend } from './types/Watcher.js';\nimport type { ChildMessage, ParentMessage } from './types/WatchMessages.js';\n\n/**\n * `ForkWatcher` runs this file to initialize the watcher in a child process.\n */\nfunction initializeWatcher() {\n // Get backend from command line arguments\n const backend = process.argv[2] as Backend | undefined;\n\n const watcher = backend === 'parcel' ? new ParcelWatcher() : new DefaultWatcher();\n\n process.on('message', (message: ParentMessage) => {\n (async () => {\n switch (message.type) {\n case 'watch':\n await watcher.watch(message.options, (changedPaths) => {\n sendMessage({ type: 'change', id: message.options.id, changedPaths });\n });\n break;\n\n case 'unwatch':\n await watcher.unwatch(message.id);\n break;\n\n case 'shutdown':\n await watcher.dispose();\n // eslint-disable-next-line no-restricted-properties -- rule isn't relevant for exiting a child process\n process.exit(0);\n }\n })().catch((error) => {\n try {\n sendMessage({ type: 'error', error: error as Error });\n } catch (sendError) {\n console.error('Failed to send error message:', sendError);\n console.error('Original error:', error);\n }\n });\n });\n}\n\n/** Typed wrapper for `process.send()` */\nfunction sendMessage(message: ChildMessage) {\n process.send?.(message);\n}\n\n// Prevent the process from exiting immediately.\n// This is handled by the parent process instead with the shutdown message.\nprocess.on('SIGINT', () => {});\n\ninitializeWatcher();\n"]}
1
+ {"version":3,"file":"watcherForkWrapper.js","sourceRoot":"","sources":["../src/watcherForkWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MA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C;gBACnB,OAAO,CAAC,KAAK,CAAC,+BAA+B,EAAE,SAAS,CAAC,CAAC;gBAC1D,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAED,yCAAyC;AACzC,SAAS,WAAW,CAAC,OAAqB;IACxC,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC;AAED,gDAAgD;AAChD,2EAA2E;AAC3E,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAE/B,iBAAiB,EAAE,CAAC","sourcesContent":["import { DefaultWatcher } from './DefaultWatcher.js';\nimport { ParcelWatcher } from './ParcelWatcher.js';\nimport type { Backend } from './types/Watcher.js';\nimport type { ChildMessage, ParentMessage } from './types/WatchMessages.js';\n\n/**\n * `ForkWatcher` runs this file to initialize the watcher in a child process.\n */\nfunction initializeWatcher() {\n // Get backend from command line arguments\n const backend = process.argv[2] as Backend | undefined;\n\n const watcher = backend === 'parcel' ? new ParcelWatcher() : new DefaultWatcher();\n\n process.on('message', (message: ParentMessage) => {\n (async () => {\n switch (message.type) {\n case 'watch':\n await watcher.watch(message.options, (changedPaths) => {\n sendMessage({ type: 'change', id: message.options.id, changedPaths });\n });\n break;\n\n case 'unwatch':\n await watcher.unwatch(message.id);\n break;\n\n case 'shutdown':\n await watcher.dispose();\n // eslint-disable-next-line no-restricted-properties -- rule isn't relevant for exiting a child process\n process.exit(0);\n }\n })().catch((error) => {\n try {\n const errorMessage = error instanceof Error ? error.message : String(error);\n sendMessage({ type: 'error', error: errorMessage });\n } catch (sendError) {\n console.error('Failed to send error message:', sendError);\n console.error('Original error:', error);\n }\n });\n });\n}\n\n/** Typed wrapper for `process.send()` */\nfunction sendMessage(message: ChildMessage) {\n process.send?.(message);\n}\n\n// Prevent the process from exiting immediately.\n// This is handled by the parent process instead with the shutdown message.\nprocess.on('SIGINT', () => {});\n\ninitializeWatcher();\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/file-watcher",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "A file watcher abstraction for use with Cloudpack.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,7 +15,7 @@
15
15
  }
16
16
  },
17
17
  "dependencies": {
18
- "@ms-cloudpack/path-utilities": "^3.1.14",
18
+ "@ms-cloudpack/path-utilities": "^3.1.15",
19
19
  "@parcel/watcher": "^2.5.1",
20
20
  "chokidar": "^3.5.3"
21
21
  },