Skip to content

Commit

Permalink
chore: add support for passing env variables (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarik02 committed Apr 28, 2023
1 parent bcb3b03 commit 2133ef2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type RunScriptWebpackPluginOptions = {
autoRestart?: boolean;
args: string[];
cwd?: string;
env?: NodeJS.ProcessEnv | undefined;
keyboard: boolean;
name?: string;
nodeArgs: string[];
Expand Down Expand Up @@ -123,13 +124,14 @@ export class RunScriptWebpackPlugin implements WebpackPluginInstance {
};

private _startServer(cb: (arg0: ChildProcess) => void): void {
const { args, nodeArgs, cwd } = this.options;
const { args, nodeArgs, cwd, env } = this.options;
if (!this._entrypoint) throw new Error('run-script-webpack-plugin requires an entrypoint.');

const child = fork(this._entrypoint, args, {
execArgv: nodeArgs,
stdio: 'inherit',
cwd,
env,
});
setTimeout(() => cb(child), 0);
}
Expand Down

0 comments on commit 2133ef2

Please sign in to comment.