Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.

Commit ca17685

Browse files
fix: use FUNCTION_TARGET to detect GCF 10 and above (#748)
1 parent 131489e commit ca17685

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/auth/envDetect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function isAppEngine() {
5252
}
5353

5454
function isCloudFunction() {
55-
return !!process.env.FUNCTION_NAME;
55+
return !!(process.env.FUNCTION_NAME || process.env.FUNCTION_TARGET);
5656
}
5757

5858
async function isKubernetesEngine() {

test/test.googleauth.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,13 +1226,20 @@ describe('googleauth', () => {
12261226
scope.done();
12271227
});
12281228

1229-
it('should get the current environment if GCF', async () => {
1229+
it('should get the current environment if GCF 8 and below', async () => {
12301230
envDetect.clear();
12311231
mockEnvVar('FUNCTION_NAME', 'DOGGY');
12321232
const env = await auth.getEnv();
12331233
assert.strictEqual(env, envDetect.GCPEnv.CLOUD_FUNCTIONS);
12341234
});
12351235

1236+
it('should get the current environment if GCF 10 and up', async () => {
1237+
envDetect.clear();
1238+
mockEnvVar('FUNCTION_TARGET', 'KITTY');
1239+
const env = await auth.getEnv();
1240+
assert.strictEqual(env, envDetect.GCPEnv.CLOUD_FUNCTIONS);
1241+
});
1242+
12361243
it('should get the current environment if GAE', async () => {
12371244
envDetect.clear();
12381245
mockEnvVar('GAE_SERVICE', 'KITTY');

0 commit comments

Comments
 (0)