From 1f1b6b0151315c26b1863adb27cc36a52d2fb18b Mon Sep 17 00:00:00 2001 From: Warren James Date: Fri, 6 Dec 2024 14:41:51 -0500 Subject: [PATCH] review fixes --- packages/bson-bench/src/common.ts | 5 +++-- packages/bson-bench/src/task.ts | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/bson-bench/src/common.ts b/packages/bson-bench/src/common.ts index ce6e88be..f3e11b41 100644 --- a/packages/bson-bench/src/common.ts +++ b/packages/bson-bench/src/common.ts @@ -1,6 +1,6 @@ import * as cp from 'child_process'; import { once } from 'events'; -import { join, sep } from 'path'; +import { join } from 'path'; import { exists } from './utils'; @@ -46,7 +46,8 @@ export class Package { this.library = match[1] as 'bson' | 'bson-ext'; this.localPath = match[2]; - this.computedModuleName = `${this.library}-local-${this.localPath.replaceAll(sep, '_')}`; + this.computedModuleName = `${this.library}-local-${this.localPath.replaceAll('/', '_')}`; + this.computedModuleName = `${this.library}-local-${this.localPath.replaceAll('\\', '_')}`; } else { throw new Error('unknown package specifier'); } diff --git a/packages/bson-bench/src/task.ts b/packages/bson-bench/src/task.ts index a835cb10..201e53e6 100644 --- a/packages/bson-bench/src/task.ts +++ b/packages/bson-bench/src/task.ts @@ -194,10 +194,12 @@ export class Task { this.children.push(child); // listen for results or error - const resultOrError: ResultMessage | ErrorMessage = (await once(child, 'message'))[0]; + const resultOrErrorPromise = once(child, 'message'); + // Wait for process to exit + const exit = once(child, 'exit'); - // wait for child to close - await once(child, 'exit'); + const resultOrError: ResultMessage | ErrorMessage = (await resultOrErrorPromise)[0]; + await exit; this.hasRun = true; switch (resultOrError.type) {