blob: f82834a043795f79f8093fe43989296945d8dee3 (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
import { describe, it } from "bun:test";
it("process", () => {
// this property isn't implemented yet but it should at least return a string
const isNode = !process.isBun;
if (!isNode && process.title !== "bun")
throw new Error("process.title is not 'bun'");
if (typeof process.env.USER !== "string")
throw new Error("process.env is not an object");
if (process.env.USER.length === 0)
throw new Error("process.env is missing a USER property");
if (process.platform !== "darwin" && process.platform !== "linux")
throw new Error("process.platform is invalid");
if (isNode) throw new Error("process.isBun is invalid");
// partially to test it doesn't crash due to various strange types
process.env.BACON = "yummy";
if (process.env.BACON !== "yummy") {
throw new Error("process.env is not writable");
}
delete process.env.BACON;
if (typeof process.env.BACON !== "undefined") {
throw new Error("process.env is not deletable");
}
process.env.BACON = "yummy";
if (process.env.BACON !== "yummy") {
throw new Error("process.env is not re-writable");
}
if (JSON.parse(JSON.stringify(process.env)).BACON !== "yummy") {
throw new Error("process.env is not serializable");
}
if (typeof JSON.parse(JSON.stringify(process.env)).toJSON !== "undefined") {
throw new Error(
"process.env should call toJSON to hide its internal state"
);
}
var { env, ...proces } = process;
console.log(JSON.stringify(proces, null, 2));
console.log(proces);
console.log("CWD", process.cwd());
console.log("SET CWD", process.chdir("../"));
console.log("CWD", process.cwd());
});
|