@travetto/manifest 3.1.0-rc.3 → 3.1.1

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.1.0-rc.3",
3
+ "version": "3.1.1",
4
4
  "description": "Support for project indexing, manifesting, along with file watching",
5
5
  "keywords": [
6
6
  "path",
package/src/path.ts CHANGED
@@ -8,7 +8,7 @@ export const path = {
8
8
  cwd,
9
9
  toPosix: posix,
10
10
  delimiter,
11
- basename: (file: string): string => posix(basename(file)),
11
+ basename: (file: string, suffix?: string): string => posix(basename(file, suffix)),
12
12
  extname: (file: string): string => posix(extname(file)),
13
13
  dirname: (file: string): string => posix(dirname(file)),
14
14
  resolve: (...args: string[]): string => posix(resolve(cwd(), ...args.map(f => posix(f)))),
package/src/util.ts CHANGED
@@ -15,12 +15,12 @@ export class ManifestUtil {
15
15
  /**
16
16
  * Write file and copy over when ready
17
17
  */
18
- static async #writeJsonWithBuffer(ctx: ManifestContext, filename: string, obj: object): Promise<string> {
19
- const tempName = `manifest.${process.ppid}.${process.pid}.json.${Date.now()}`;
20
- const file = path.resolve(ctx.workspacePath, ctx.outputFolder, 'node_modules', ctx.mainModule, filename);
18
+ static async writeFileWithBuffer(file: string, content: string): Promise<string> {
19
+ const ext = path.extname(file);
20
+ const tempName = `${path.basename(file, ext)}.${process.ppid}.${process.pid}.${Date.now()}.${Math.random()}.${ext}`;
21
21
  await fs.mkdir(path.dirname(file), { recursive: true });
22
22
  const temp = path.resolve(os.tmpdir(), tempName);
23
- await fs.writeFile(temp, JSON.stringify(obj), 'utf8');
23
+ await fs.writeFile(temp, content, 'utf8');
24
24
  await fs.copyFile(temp, file);
25
25
  fs.unlink(temp);
26
26
  return file;
@@ -88,7 +88,10 @@ export class ManifestUtil {
88
88
  * Write manifest for a given context, return location
89
89
  */
90
90
  static writeManifest(ctx: ManifestContext, manifest: ManifestRoot): Promise<string> {
91
- return this.#writeJsonWithBuffer(ctx, MANIFEST_FILE, manifest);
91
+ return this.writeFileWithBuffer(
92
+ path.resolve(ctx.workspacePath, ctx.outputFolder, 'node_modules', ctx.mainModule, MANIFEST_FILE),
93
+ JSON.stringify(manifest)
94
+ );
92
95
  }
93
96
 
94
97
  /**