Skip to content

Commit

Permalink
feat: platform agnostic process
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 9, 2023
1 parent 3c547d8 commit 48b4fc0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ List of well known providers can be found from [./src/providers.ts](./src/provid
import { env } from "std-env";
```

## Platform agnostic process

`std-env` provides a lightweight proxy to access [`process`](https://nodejs.org/api/process.html) object in a platform agnostic way.

```ts
import { process } from "std-env";
```

## License

MIT
2 changes: 0 additions & 2 deletions src/_process.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./providers";
export * from "./env";
export * from "./flags";
export * from "./process";
export * from "./providers";
12 changes: 12 additions & 0 deletions src/process.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { env } from "./env";

export const process = new Proxy(globalThis.process || Object.create(null), {
get(target, prop) {
if (prop in target) {
return target[prop];
}
if (prop === "env") {
return env;
}
},
});
3 changes: 2 additions & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ describe("std-env", () => {
it("has expected exports", () => {
expect(Object.keys(stdEnv)).toMatchInlineSnapshot(`
[
"detectProvider",
"env",
"nodeENV",
"platform",
Expand All @@ -23,6 +22,8 @@ describe("std-env", () => {
"isLinux",
"isMacOS",
"isColorSupported",
"process",
"detectProvider",
]
`);
});
Expand Down

0 comments on commit 48b4fc0

Please sign in to comment.