@travetto/manifest 3.3.0 → 3.3.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.
package/README.md CHANGED
@@ -85,7 +85,7 @@ Once the manifest is created, the application runtime can now read this manifest
85
85
  * Providing contextual information when provided a filename, import name, etc (e.g. logging, testing output)
86
86
 
87
87
  ## Path Normalization
88
- By default, all paths within the framework are assumed to be in a POSIX style, and all input paths are converted to the POSIX style. This works appropriately within a Unix and a Windows environment. This module offers up [path](https://github.com/travetto/travetto/tree/main/module/manifest/src/path.ts#L8) as an equivalent to [Node](https://nodejs.org)'s [http](https://nodejs.org/api/path.html) library. This allows for consistent behavior across all file-interactions, and also allows for easy analysis if [Node](https://nodejs.org)'s [http](https://nodejs.org/api/path.html) library is ever imported.
88
+ By default, all paths within the framework are assumed to be in a POSIX style, and all input paths are converted to the POSIX style. This works appropriately within a Unix and a Windows environment. This module offers up [path](https://github.com/travetto/travetto/tree/main/module/manifest/src/path.ts#L21) as an equivalent to [Node](https://nodejs.org)'s [http](https://nodejs.org/api/path.html) library. This allows for consistent behavior across all file-interactions, and also allows for easy analysis if [Node](https://nodejs.org)'s [http](https://nodejs.org/api/path.html) library is ever imported.
89
89
 
90
90
  ## File Watching
91
91
  The module also leverages [@parcel/watcher](https://www.npmjs.com/package/@parcel/watcher), to expose a single function of `watchFolders`. Only the [Compiler](https://github.com/travetto/travetto/tree/main/module/compiler#readme "The compiler infrastructure for the Travetto framework") module packages [@parcel/watcher](https://www.npmjs.com/package/@parcel/watcher) as a direct dependency. This means, that in production, by default all watch operations will fail with a missing dependency.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/manifest",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "description": "Support for project indexing, manifesting, along with file watching",
5
5
  "keywords": [
6
6
  "path",
package/src/path.ts CHANGED
@@ -1,17 +1,35 @@
1
- import { extname, dirname, resolve, basename, join } from 'path/posix';
2
- import { sep } from 'path';
1
+ import type * as pathMod from 'path';
2
+ import { extname, dirname, basename, resolve, join } from 'path/posix';
3
+ import { sep, resolve as nativeResolve, join as nativeJoin } from 'path';
3
4
 
4
- const posix = (file: string): string => file.replaceAll('\\', '/');
5
+ /**
6
+ * Converts a given file name by replace all slashes, with forward slashes
7
+ */
8
+ const toPosix = (file: string): string => file.replaceAll('\\', '/');
9
+ /**
10
+ * Converts a given file name by replace all slashes, with platform dependent path separators
11
+ */
12
+ const toNative = (file: string): string => file.replaceAll('/', sep);
5
13
 
6
- const cwd = (): string => posix(process.cwd());
14
+ const cwd = (): string => toPosix(process.cwd());
7
15
 
8
- export const path = {
16
+ type PathModType =
17
+ { toPosix: typeof toPosix, toNative: typeof toNative } &
18
+ Pick<typeof pathMod, 'basename' | 'dirname' | 'extname' | 'join' | 'resolve'> &
19
+ Pick<typeof process, 'cwd'>;
20
+
21
+ export const path: PathModType = {
9
22
  cwd,
10
- toPosix: posix,
11
- basename: (file: string, suffix?: string): string => basename(posix(file), suffix),
12
- extname: (file: string): string => extname(posix(file)),
13
- dirname: (file: string): string => dirname(posix(file)),
14
- resolve: (...args: string[]): string => resolve(cwd(), ...args.map(f => posix(f))),
15
- join: (root: string, ...args: string[]): string => join(posix(root), ...args.map(f => posix(f))),
16
- toNative: (file: string): string => file.replaceAll('/', sep)
17
- };
23
+ toPosix,
24
+ toNative,
25
+ basename: (file, suffix) => basename(toPosix(file), suffix),
26
+ extname: file => extname(toPosix(file)),
27
+ dirname: file => dirname(toPosix(file)),
28
+ resolve: (...args) => resolve(cwd(), ...args.map(toPosix)),
29
+ join: (...args) => join(...args.map(toPosix)),
30
+ };
31
+
32
+ if (process.platform === 'win32') {
33
+ path.resolve = (...args: string[]): string => toPosix(nativeResolve(cwd(), ...args.map(toPosix)));
34
+ path.join = (root: string, ...args: string[]): string => toPosix(nativeJoin(toPosix(root), ...args.map(toPosix)));
35
+ }
package/src/watch.ts CHANGED
@@ -158,6 +158,9 @@ async function watchFolderRecursive(queue: Queue<WatchEvent>, options: WatchFold
158
158
  await fs.mkdir(options.src, { recursive: true });
159
159
  const ignore = (await fs.readdir(options.src)).filter(x => x.startsWith('.') && x.length > 2);
160
160
  const cleanup = await lib.subscribe(options.src, async (err, events) => {
161
+ if (err) {
162
+ process.send?.({ type: 'log', message: `Watch error: ${err}` });
163
+ }
161
164
  for (const ev of events) {
162
165
  const finalEv = { action: ev.type, file: path.toPosix(ev.path), folder: target };
163
166
  if (ev.type !== 'delete') {