@travetto/manifest 3.0.0-rc.15 → 3.0.0-rc.16

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.15",
3
+ "version": "3.0.0-rc.16",
4
4
  "description": "Manifest support",
5
5
  "keywords": [
6
6
  "path",
package/src/util.ts CHANGED
@@ -16,10 +16,10 @@ export class ManifestUtil {
16
16
  * Write file and copy over when ready
17
17
  */
18
18
  static async #writeJsonWithBuffer(ctx: ManifestContext, filename: string, obj: object): Promise<string> {
19
- const tempName = path.resolve(ctx.workspacePath, ctx.mainFolder, filename).replace(/[\/\\: ]/g, '_');
19
+ const tempName = `manifest.${process.ppid}.${process.pid}.json.${Date.now()}`;
20
20
  const file = path.resolve(ctx.workspacePath, ctx.outputFolder, 'node_modules', ctx.mainModule, filename);
21
21
  await fs.mkdir(path.dirname(file), { recursive: true });
22
- const temp = path.resolve(os.tmpdir(), `${tempName}.${Date.now()}`);
22
+ const temp = path.resolve(os.tmpdir(), tempName);
23
23
  await fs.writeFile(temp, JSON.stringify(obj), 'utf8');
24
24
  await fs.copyFile(temp, file);
25
25
  fs.unlink(temp);
package/src/watch.ts CHANGED
@@ -5,7 +5,7 @@ export type WatchEvent = { action: 'create' | 'update' | 'delete', file: string
5
5
 
6
6
  export type WatchEventListener = (ev: WatchEvent, folder: string) => void;
7
7
  type EventFilter = (ev: WatchEvent) => boolean;
8
- type WatchConfig = { filter?: EventFilter, ignore?: string[], createMissing?: boolean };
8
+ type WatchConfig = { filter?: EventFilter, ignore?: string[], createMissing?: boolean, includeHidden?: boolean };
9
9
 
10
10
  async function getWatcher(): Promise<typeof import('@parcel/watcher')> {
11
11
  try {
@@ -40,11 +40,11 @@ export async function watchFolders(
40
40
  const ignore = (await fs.readdir(folder)).filter(x => x.startsWith('.') && x.length > 2);
41
41
  return lib.subscribe(folder, (err, events) => {
42
42
  for (const ev of events) {
43
- if (ev.type === 'delete' && validFolders.has(path.toPosix(ev.path))) {
43
+ const finalEv = { action: ev.type, file: path.toPosix(ev.path) };
44
+ if (ev.type === 'delete' && validFolders.has(finalEv.file)) {
44
45
  return process.exit(0); // Exit when watched folder is removed
45
46
  }
46
- const finalEv = { action: ev.type, file: ev.path };
47
- if (!config.filter || config.filter(finalEv)) {
47
+ if ((config.includeHidden || !finalEv.file.includes('/.')) && (!config.filter || config.filter(finalEv))) {
48
48
  onEvent(finalEv, targetFolder);
49
49
  }
50
50
  }