Skip to content

Commit cc528ba

Browse files
committed
Can now pass environment variables through to the Electron process.
1 parent 57871f1 commit cc528ba

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "capture-template",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"description": "This library is responsible for expanding a template web page and then capturing it PNG or PDF.",
55
"main": "build/index.js",
66
"types": "build/index.d.ts",

src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export interface ILog {
2424
error(msg: string): void;
2525
}
2626

27+
/**
28+
* Environment variables to pass in when starting the Electrong process required for capturing.
29+
*/
30+
export interface IEnvVars {
31+
[index: string]: string;
32+
}
33+
2734
/**
2835
* Specifies options that can be passed to the capture function.
2936
*/
@@ -58,6 +65,11 @@ export interface ICaptureOptions {
5865
* Specify the path to Electron if that's necessary for you.
5966
*/
6067
electronPath?: string;
68+
69+
/**
70+
* Environment variables to pass in when starting the Electrong process required for capturing.
71+
*/
72+
env?: IEnvVars;
6173
}
6274

6375
//

src/web-page-renderer.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,16 @@ export class WebPageRenderer implements IWebPageRenderer {
118118
openDevTools: this.options && this.options.openDevTools,
119119
};
120120

121-
if (this.options && this.options.electronPath) {
122-
// Include Electron path if specified.
123-
nightmareOptions.electronPath = this.options.electronPath;
121+
if (this.options) {
122+
if (this.options.electronPath) {
123+
// Include Electron path if specified.
124+
nightmareOptions.electronPath = this.options.electronPath;
125+
}
126+
127+
if (this.options.env) {
128+
// Include Electron environment variables if specified.
129+
nightmareOptions.env = this.options.env;
130+
}
124131
}
125132

126133
this.nightmare = new Nightmare(nightmareOptions);

0 commit comments

Comments
 (0)