Skip to content

Commit 956e52c

Browse files
committed
fix(exportfunctions): process.env.FUNCTION_NAME is now called K_SERVICE
Firebase has changed the environment variable where the name of the currently invoked function is stored. This commit adresses that change. fix #7
1 parent cd5d255 commit 956e52c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/default.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default function (__dirname: string, __filename: string, exports: any, di
5656
const relPath = absPath.substr(absFuncDir.length + 1); /* ? */
5757
const funcName = funcNameFromRelPath(relPath); /* ? */
5858
const propPath = funcName.replace(/-/g, '.'); /* ? */
59-
if (!process.env.FUNCTION_NAME || process.env.FUNCTION_NAME === funcName) {
59+
if (!process.env.K_SERVICE || process.env.K_SERVICE === funcName) {
6060
// eslint-disable-next-line import/no-dynamic-require, global-require, no-eval
6161
const module = eval('require')(resolve(__dirname, funcDir, relPath));
6262
if (!module.default) continue;

src/export-functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ const disabledLogger = {
130130
},
131131
};
132132

133-
const getFunctionInstance = () => process.env.FUNCTION_NAME;
133+
const getFunctionInstance = () => process.env.K_SERVICE;
134134
const isDeployment = () => !getFunctionInstance();
135135
const funcNameMatchesInstance = (funcName: string) => funcName === getFunctionInstance();
136136
const getTriggerFromModule = (inputModule: any) => inputModule?.default;

0 commit comments

Comments
 (0)