Files
bun.sh/test/cli/run/run-process-env.test.ts
Dylan Conway c39c11e101 structured clone (#3637)
* copy `SerializedScriptValue`

* format

* make `SerializedScriptValue` compile

* add `transfer` option

* tests

* serialize/deserialize blobs

* tests for blobs

* serialize/deserialize file blobs

* more tests

* small cleanup

* format

* small changes + serialize offset

* slice helper

* map and set test
2023-07-14 19:37:22 -07:00

31 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": `{'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": `{"scripts": { "first": "${bunExe()} run --cwd lsc second" } }`,
"lsc": {
"package.json": `{"scripts": { "second": "${bunExe()} run index.ts" } }`,
"index.ts": "console.log(process.env.npm_lifecycle_event);",
},
});
const { stdout } = bunRunAsScript(dir, "first");
expect(stdout).toBe("second");
});
});