Files
bun.sh/test/cli/run/run-process-env.test.ts
Jarred Sumner 76ced7c6ed WIP Make process.stdout sync on windows (#9398)
* Make some things sync on windows

* WIP

* WIP

* remove uses to uv_default_loop

* remove a compiler warning on windows

* edfghjk

* Windows build fixes

* Fixup

* bundows

* Add quotes

* Fix --cwd arg on Windows

* comment

* move this up

* Fix some tests

* `mv` tests pass

* spawn.test passes again

* Allow .sh file extension for Windows

* Unmark failing tests

* env test pass

* windows

* Fix some tests

* Update ProcessBindingTTYWrap.cpp

* Update CMakeLists.txt

* Set tmpdir

* Make it 5s on windows

* Fixup

* Fixup

* Update ProcessBindingTTYWrap.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: dave caruso <me@paperdave.net>
2024-03-18 19:35:34 -07:00

29 lines
1.1 KiB
TypeScript

import { describe, expect, test } from "bun:test";
import { bunExe, bunRunAsScript, tempDirWithFiles } from "harness";
describe("process.env", () => {
test("npm_lifecycle_event", () => {
const scriptName = "start:dev";
const dir = tempDirWithFiles("processenv", {
"package.json": JSON.stringify({ "scripts": { [`${scriptName}`]: `'${bunExe()}' run index.ts` } }),
"index.ts": "console.log(process.env.npm_lifecycle_event);",
});
const { stdout } = bunRunAsScript(dir, scriptName);
expect(stdout).toBe(scriptName);
});
// https://github.com/oven-sh/bun/issues/3589
test("npm_lifecycle_event should have the value of the last call", () => {
const dir = tempDirWithFiles("processenv_ls_call", {
"package.json": JSON.stringify({ scripts: { first: `'${bunExe()}' run --cwd lsc second` } }),
"lsc": {
"package.json": JSON.stringify({ scripts: { second: `'${bunExe()}' run index.ts` } }),
"index.ts": "console.log(process.env.npm_lifecycle_event);",
},
});
const { stdout } = bunRunAsScript(dir, "first");
expect(stdout).toBe("second");
});
});