@travetto/compiler 5.0.0-rc.0 → 5.0.0-rc.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/compiler",
3
- "version": "5.0.0-rc.0",
3
+ "version": "5.0.0-rc.2",
4
4
  "description": "The compiler infrastructure for the Travetto framework",
5
5
  "keywords": [
6
6
  "compiler",
@@ -31,12 +31,12 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@parcel/watcher": "^2.4.1",
34
- "@travetto/manifest": "^5.0.0-rc.0",
35
- "@travetto/transformer": "^5.0.0-rc.0",
34
+ "@travetto/manifest": "^5.0.0-rc.1",
35
+ "@travetto/transformer": "^5.0.0-rc.1",
36
36
  "@types/node": "^20.14.10"
37
37
  },
38
38
  "peerDependencies": {
39
- "@travetto/cli": "^5.0.0-rc.0"
39
+ "@travetto/cli": "^5.0.0-rc.1"
40
40
  },
41
41
  "peerDependenciesMeta": {
42
42
  "@travetto/cli": {
@@ -71,10 +71,9 @@ export const main = (ctx: ManifestContext) => {
71
71
 
72
72
  /** Stream events */
73
73
  events: async (type: string, handler: (ev: unknown) => unknown): Promise<void> => {
74
- if (type === 'change' || type === 'log' || type === 'progress' || type === 'state') {
75
- for await (const ev of client.fetchEvents(type)) { await handler(ev); }
76
- } else if (type === 'all') {
77
- for await (const ev of client.fetchEvents(type)) { await handler(ev); }
74
+ if (type === 'change' || type === 'log' || type === 'progress' || type === 'state' || type === 'all') {
75
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
76
+ for await (const ev of client.fetchEvents(type as 'change')) { await handler(ev); }
78
77
  } else {
79
78
  throw new Error(`Unknown event type: ${type}`);
80
79
  }
@@ -21,7 +21,8 @@ export class ProcessHandle {
21
21
  }
22
22
 
23
23
  getPid(): Promise<number | undefined> {
24
- return fs.readFile(this.#file, 'utf8').then(v => +v, () => undefined);
24
+ return fs.readFile(this.#file, 'utf8')
25
+ .then(v => +v > 0 ? +v : undefined, () => undefined);
25
26
  }
26
27
 
27
28
  async isRunning(): Promise<boolean> {
@@ -190,9 +190,13 @@ export class CompilerServer {
190
190
 
191
191
  if (ev.type === 'state') {
192
192
  this.info.state = ev.payload.state;
193
- await this.#handle.compiler.writePid(this.info.compilerPid);
194
193
  if (ev.payload.state === 'init' && ev.payload.extra && 'pid' in ev.payload.extra && typeof ev.payload.extra.pid === 'number') {
194
+ if (this.info.mode === 'watch' && !this.info.compilerPid) {
195
+ // Ensure we are killing in watch mode on first set
196
+ await this.#handle.compiler.kill();
197
+ }
195
198
  this.info.compilerPid = ev.payload.extra.pid;
199
+ await this.#handle.compiler.writePid(this.info.compilerPid);
196
200
  }
197
201
  log.info(`State changed: ${this.info.state}`);
198
202
  } else if (ev.type === 'log') {
@@ -249,4 +253,4 @@ export class CompilerServer {
249
253
  log.info(running ? 'Starting server' : 'Server already running under a different process', this.#url);
250
254
  return running ? this : undefined;
251
255
  }
252
- }
256
+ }