Skip to content

Commit 2c14cab

Browse files
committed
added envar parse
1 parent c2f08a0 commit 2c14cab

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

constants.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,30 @@ export const FORMULA_KEYS = [
9494
];
9595

9696
export const GOOGLE_SHEET_ID = () => {
97-
let sheetId;
98-
99-
if (shadowConfigDetails && shadowConfigDetails.googleSpreadsheetId) {
100-
sheetId = shadowConfigDetails.googleSpreadsheetId
101-
.split('/d/')[1]
102-
.split('/')[0];
103-
} else {
104-
sheetId = false;
97+
let sheetId = '';
98+
99+
if (
100+
shadowConfigDetails &&
101+
typeof shadowConfigDetails.googleSpreadsheetId === 'string'
102+
) {
103+
const envVarMatch = shadowConfigDetails.googleSpreadsheetId.match(
104+
/^process\.env\.(\w+)$/
105+
);
106+
107+
if (envVarMatch) {
108+
const envVarName = envVarMatch[1]; // Extract the environment variable name (e.g., 'SHEET_ID')
109+
110+
// Check if the environment variable exists in process.env
111+
if (process.env[envVarName]) {
112+
sheetId = process.env[envVarName].split('/d/')[1].split('/')[0] || ''; // Set the value from process.env
113+
}
114+
} else {
115+
sheetId = shadowConfigDetails.googleSpreadsheetId
116+
.split('/d/')[1]
117+
.split('/')[0]; // Use the raw config value if it's not an environment variable
118+
}
105119
}
120+
106121
return sheetId;
107122
};
108123

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "qa-shadow-report",
3-
"version": "1.1.31",
3+
"version": "1.1.32",
44
"bin": {
55
"qa-shadow-report": "./cli.js",
66
"qasr": "./cli.js",

0 commit comments

Comments
 (0)