From 9f63979571728954ded876011cf2c3ff05ee058e Mon Sep 17 00:00:00 2001 From: Ashton Eby Date: Thu, 21 Nov 2024 09:40:51 -0800 Subject: [PATCH] try to fix tests --- scripts/update-prod-hashbang.mjs | 5 +++++ test/general-cli.mjs | 22 ++++++++++++++-------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/scripts/update-prod-hashbang.mjs b/scripts/update-prod-hashbang.mjs index bf7969a0..a6fabc22 100644 --- a/scripts/update-prod-hashbang.mjs +++ b/scripts/update-prod-hashbang.mjs @@ -1,5 +1,6 @@ #!/usr/bin/env node import * as fs from "node:fs"; +import * as fsp from "node:fs/promises"; import * as path from "node:path"; const __dirname = import.meta.dirname; @@ -12,4 +13,8 @@ fileContents = `#!/usr/bin/env NODE_NO_WARNINGS=1 node\n${fileContents}`; fs.rmSync(filePath); fs.writeFileSync(filePath, fileContents, { mode: 0o755, + flush: true, }); + +// eslint-disable-next-line no-console +fsp.stat(filePath).then(console.log); diff --git a/test/general-cli.mjs b/test/general-cli.mjs index 971e95c4..ebe51430 100644 --- a/test/general-cli.mjs +++ b/test/general-cli.mjs @@ -126,11 +126,14 @@ describe("cli operations", function () { }); it("enables nodeJS warnings from the dev entrypoint", async function () { - let stderr = spawnSync("./src/user-entrypoint.mjs", ["warn"], { + let cli = spawnSync("./src/user-entrypoint.mjs", ["warn"], { encoding: "utf8", - shell: true, - stdio: "pipe", - }).stderr; + input: "", + timeout: 5000, + stdio: ["inherit", "pipe", "pipe"], + }); + if (cli.error) throw cli.error; + let stderr = cli.stderr; // the dev script should emit warnings expect(stderr).to.include( @@ -139,11 +142,14 @@ describe("cli operations", function () { }); it("suppresses nodeJS warnings from the prod entrypoint", async function () { - let stderr = spawnSync("./dist/cli.cjs", ["warn"], { + let cli = spawnSync("./dist/cli.cjs", ["warn"], { encoding: "utf8", - shell: true, - stdio: "pipe", - }).stderr; + input: "", + timeout: 5000, + stdio: ["inherit", "pipe", "pipe"], + }); + if (cli.error) throw cli.error; + let stderr = cli.stderr; // the prod one should not expect(stderr).to.equal("");