@epic-web/app-launcher
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -1,2 +0,2 @@ | ||
import { type ChildProcessWithoutNullStreams } from 'node:child_process'; | ||
import { type ChildProcess } from 'node:child_process'; | ||
export interface AppProcessOptions { | ||
@@ -15,5 +15,5 @@ command: string; | ||
get url(): URL; | ||
launch(): Promise<ChildProcessWithoutNullStreams>; | ||
launch(): Promise<ChildProcess>; | ||
dispose(): Promise<void>; | ||
[Symbol.asyncDispose](): Promise<void>; | ||
} |
@@ -1,2 +0,2 @@ | ||
import type { ChildProcessWithoutNullStreams } from 'node:child_process'; | ||
import type { ChildProcess } from 'node:child_process'; | ||
import { AppProcess } from './app-process.js'; | ||
@@ -11,2 +11,6 @@ export interface DefineLauncherOptions<Context> { | ||
/** | ||
* Run the launcher in debug mode. | ||
*/ | ||
debug?: boolean; | ||
/** | ||
* Define a context object exposed to the other launcher methods. | ||
@@ -64,3 +68,3 @@ * | ||
env: Record<string, string>; | ||
appProcess: ChildProcessWithoutNullStreams; | ||
appProcess: ChildProcess; | ||
}) => string | URL | Promise<string | URL>; | ||
@@ -67,0 +71,0 @@ } |
@@ -25,2 +25,6 @@ import { AppProcess, kUrl } from './app-process.js'; | ||
const childProcess = await app.launch(); | ||
if (options?.debug) { | ||
childProcess.stdout?.pipe(process.stdout); | ||
childProcess.stderr?.pipe(process.stderr); | ||
} | ||
// Wait for the provided application URL to be up. | ||
@@ -27,0 +31,0 @@ const url = await options.url({ |
{ | ||
"type": "module", | ||
"name": "@epic-web/app-launcher", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Utility for launching your applications on a per-test basis.", | ||
@@ -9,2 +9,3 @@ "main": "./build/index.js", | ||
"scripts": { | ||
"dev": "npm run build -- --watch", | ||
"test": "vitest", | ||
@@ -11,0 +12,0 @@ "build": "tsc -p ./tsconfig.build.json", |
@@ -1,2 +0,2 @@ | ||
import { type ChildProcessWithoutNullStreams, spawn } from 'node:child_process' | ||
import { type ChildProcess, spawn } from 'node:child_process' | ||
import { DeferredPromise } from '@open-draft/deferred-promise' | ||
@@ -14,3 +14,3 @@ import { invariant } from '@epic-web/invariant' | ||
export class AppProcess { | ||
private io?: ChildProcessWithoutNullStreams | ||
private io?: ChildProcess | ||
private controller: AbortController | ||
@@ -34,3 +34,3 @@ private [kUrl]?: URL | ||
public async launch(): Promise<ChildProcessWithoutNullStreams> { | ||
public async launch(): Promise<ChildProcess> { | ||
const [command, ...args] = this.options.command.split(' ') | ||
@@ -37,0 +37,0 @@ |
@@ -1,2 +0,2 @@ | ||
import type { ChildProcessWithoutNullStreams } from 'node:child_process' | ||
import type { ChildProcess } from 'node:child_process' | ||
import { AppProcess, kUrl } from './app-process.js' | ||
@@ -14,2 +14,7 @@ import { waitForPort } from './wait-for-port.js' | ||
/** | ||
* Run the launcher in debug mode. | ||
*/ | ||
debug?: boolean | ||
/** | ||
* Define a context object exposed to the other launcher methods. | ||
@@ -70,3 +75,3 @@ * | ||
env: Record<string, string> | ||
appProcess: ChildProcessWithoutNullStreams | ||
appProcess: ChildProcess | ||
}) => string | URL | Promise<string | URL> | ||
@@ -113,2 +118,7 @@ } | ||
if (options?.debug) { | ||
childProcess.stdout?.pipe(process.stdout) | ||
childProcess.stderr?.pipe(process.stderr) | ||
} | ||
// Wait for the provided application URL to be up. | ||
@@ -115,0 +125,0 @@ const url = await options.url({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
27044
513