Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove json path and fix process check #6665

Merged
merged 2 commits into from Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strong-squids-dress.md
@@ -0,0 +1,5 @@
---
'@firebase/util': patch
---

Remove `__FIREBASE_DEFAULTS_PATH__` option for now, as the current implementation causes Webpack warnings. Also fix `process.env` check to work in environments where `process` exists but `process.env` does not.
22 changes: 1 addition & 21 deletions packages/util/src/defaults.ts
Expand Up @@ -57,33 +57,13 @@ const getDefaultsFromGlobal = (): FirebaseDefaults | undefined =>
* process.env.__FIREBASE_DEFAULTS_PATH__
*/
const getDefaultsFromEnvVariable = (): FirebaseDefaults | undefined => {
if (typeof process === 'undefined') {
if (typeof process === 'undefined' || typeof process.env === 'undefined') {
return;
}
const defaultsJsonString = process.env.__FIREBASE_DEFAULTS__;
const defaultsJsonPath = process.env.__FIREBASE_DEFAULTS_PATH__;
if (defaultsJsonString) {
if (defaultsJsonPath) {
console.warn(
`Values were provided for both __FIREBASE_DEFAULTS__ ` +
`and __FIREBASE_DEFAULTS_PATH__. __FIREBASE_DEFAULTS_PATH__ ` +
`will be ignored.`
);
}
return JSON.parse(defaultsJsonString);
}
if (defaultsJsonPath && typeof require !== 'undefined') {
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
const json = require(defaultsJsonPath);
return json;
} catch (e) {
console.warn(
`Unable to read defaults from file provided to ` +
`__FIREBASE_DEFAULTS_PATH__: ${defaultsJsonPath}`
);
}
}
};

const getDefaultsFromCookie = (): FirebaseDefaults | undefined => {
Expand Down