aboutsummaryrefslogtreecommitdiff
path: root/test/cli/run/run-process-env.test.ts
blob: 8303fe19cc240a707379e1551acd1c760531c222 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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");
  });
});
n title='2023-08-10 22:15:07 -0700'>2023-08-10async realpath (#4117)Gravatar Jarred Sumner 6-58/+184 2023-08-10Remove assertionGravatar Jarred Sumner 1-3/+0 2023-08-10More lazily initialize these static stringsGravatar Jarred Sumner 1-5/+7 2023-08-10don't check for trailing slash, var streamGravatar Dylan Conway 3-9/+9 2023-08-10run files without extensions (#4113)Gravatar Dylan Conway 4-11/+46 2023-08-10Fix memory leak in base64url (#4111)Gravatar Jarred Sumner 1-2/+2 2023-08-10Handle thundering herd of setInterval (#4109)Gravatar Jarred Sumner 1-2/+17 2023-08-10fs.zig: create temp files with 0o700, not 0o007 (#4107)Gravatar Adhityaa Chandrasekar 1-1/+1 2023-08-10Update remix guideGravatar Colin McDonnell 1-2/+4 2023-08-10zig fmtGravatar Jarred Sumner 1-4/+4 2023-08-10Fixes #4062 (#4106)Gravatar Jarred Sumner 8-26/+87 2023-08-10bun test: format description of test.each (#4092)Gravatar Jacques 3-13/+311 2023-08-10add util.formatWithOptions (#4090)Gravatar dave caruso 3-9/+30 2023-08-10Fix titleGravatar Colin McDonnell 1-1/+1