Skip to content

Commit 233da66

Browse files
committed
feat(context): add env to AppContext using RenderOptions
1 parent 7fd0574 commit 233da66

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

docs/api/interfaces/AppProps.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ Props for the AppContext.
1010

1111
## Properties
1212

13+
### env?
14+
15+
> `readonly` `optional` **env**: `Record`\<`string`, `string` \| `undefined`\>
16+
17+
Environment variables.
18+
19+
---
20+
1321
### exit()
1422

1523
> `readonly` **exit**: (`error?`) => `void`
@@ -25,3 +33,11 @@ Exit (unmount) the whole Tinky app.
2533
#### Returns
2634

2735
`void`
36+
37+
---
38+
39+
### platform?
40+
41+
> `readonly` `optional` **platform**: `string`
42+
43+
The platform the app is running on.

src/components/App.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ interface AppProps {
5757
* Callback called when the app exits.
5858
*/
5959
readonly onExit: (error?: Error) => void;
60+
61+
/**
62+
* Environment variables.
63+
*/
64+
readonly env?: Record<string, string | undefined>;
6065
}
6166

6267
/**
@@ -136,6 +141,7 @@ export class App extends PureComponent<AppProps, State> {
136141
value={{
137142
exit: this.handleExit,
138143
platform: process?.platform,
144+
env: this.props.env,
139145
}}
140146
>
141147
<StdinContext.Provider

src/contexts/AppContext.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export interface AppProps {
1313
* The platform the app is running on.
1414
*/
1515
readonly platform?: string;
16+
17+
/**
18+
* Environment variables.
19+
*/
20+
readonly env?: Record<string, string | undefined>;
1621
}
1722

1823
/**

src/core/tinky.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ export class Tinky {
446446
writeToStderr={this.writeToStderr}
447447
exitOnCtrlC={this.options.exitOnCtrlC}
448448
onExit={this.unmount}
449+
env={this.options.env}
449450
>
450451
{node}
451452
</App>

0 commit comments

Comments
 (0)