Skip to content

Commit eb2952e

Browse files
authored
Prettier changes (firebase#397)
1 parent 8052eaa commit eb2952e

File tree

6 files changed

+38
-31
lines changed

6 files changed

+38
-31
lines changed

integration_test/functions/src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as functions from 'firebase-functions';
22
import * as https from 'https';
33
import * as admin from 'firebase-admin';
44
import { Request, Response } from 'express';
5-
import * as fs from 'fs'
5+
import * as fs from 'fs';
66

77
import * as PubSub from '@google-cloud/pubsub';
88
const pubsub = PubSub();
@@ -59,7 +59,7 @@ export const integrationTests: any = functions
5959
.ref()
6060
.push().key;
6161
console.log('testId is: ', testId);
62-
fs.writeFile('/tmp/' + testId + '.txt', 'test', ()=> {});
62+
fs.writeFile('/tmp/' + testId + '.txt', 'test', () => {});
6363
return Promise.all([
6464
// A database write to trigger the Firebase Realtime Database tests.
6565
admin
@@ -93,7 +93,7 @@ export const integrationTests: any = functions
9393
admin.credential
9494
.applicationDefault()
9595
.getAccessToken()
96-
.then((accessToken) => {
96+
.then(accessToken => {
9797
const options = {
9898
hostname: 'firebaseremoteconfig.googleapis.com',
9999
path: `/v1/projects/${firebaseConfig.projectId}/remoteConfig`,
@@ -110,7 +110,10 @@ export const integrationTests: any = functions
110110
request.end();
111111
}),
112112
// A storage upload to trigger the Storage tests
113-
admin.storage().bucket().upload('/tmp/' + testId + '.txt'),
113+
admin
114+
.storage()
115+
.bucket()
116+
.upload('/tmp/' + testId + '.txt'),
114117
// Invoke a callable HTTPS trigger.
115118
callHttpsTrigger('callableTests', { foo: 'bar', testId }),
116119
])

integration_test/functions/src/storage-tests.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ export const storageTests: any = functions
77
.runWith({
88
timeoutSeconds: 540,
99
})
10-
.storage.bucket().object()
10+
.storage.bucket()
11+
.object()
1112
.onFinalize((s, c) => {
1213
const testId = s.name.split('.')[0];
1314
return new TestSuite<ObjectMetadata>('storage object finalize')

spec/function-builder.spec.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ describe('FunctionBuilder', () => {
4848
.auth.user()
4949
.onCreate(user => user);
5050

51-
expect(fn.__trigger.regions).to.deep.equal([
52-
'us-east1',
53-
'us-central1',
54-
]);
51+
expect(fn.__trigger.regions).to.deep.equal(['us-east1', 'us-central1']);
5552
});
5653

5754
it('should allow runtime options to be set', () => {
@@ -158,5 +155,4 @@ describe('FunctionBuilder', () => {
158155
} as any);
159156
}).to.throw(Error);
160157
});
161-
162158
});

spec/providers/database.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,17 +251,17 @@ describe('Database Functions', () => {
251251
return database.resourceToInstanceAndPath(
252252
'projects/_/instances/a.bad.name/refs/bar'
253253
);
254-
}).to.throw(Error)
254+
}).to.throw(Error);
255255
expect(() => {
256256
return database.resourceToInstanceAndPath(
257257
'projects/_/instances/a_different_bad_name/refs/bar'
258258
);
259-
}).to.throw(Error)
259+
}).to.throw(Error);
260260
expect(() => {
261261
return database.resourceToInstanceAndPath(
262262
'projects/_/instances/BAD!!!!/refs/bar'
263263
);
264-
}).to.throw(Error)
264+
}).to.throw(Error);
265265
});
266266
});
267267

src/function-builder.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ import * as https from './providers/https';
3232
import * as pubsub from './providers/pubsub';
3333
import * as remoteConfig from './providers/remoteConfig';
3434
import * as storage from './providers/storage';
35-
import { CloudFunction, EventContext, Runnable, TriggerAnnotated } from './cloud-functions';
35+
import {
36+
CloudFunction,
37+
EventContext,
38+
Runnable,
39+
TriggerAnnotated,
40+
} from './cloud-functions';
3641

3742
/**
3843
* Configure the regions that the function is deployed to.
@@ -41,15 +46,15 @@ import { CloudFunction, EventContext, Runnable, TriggerAnnotated } from './cloud
4146
*/
4247
export function region(...regions: string[]) {
4348
if (!regions.length) {
44-
throw new Error(
45-
"You must specify at least one region"
46-
);
49+
throw new Error('You must specify at least one region');
4750
}
4851
if (
49-
_.difference(
50-
regions,
51-
['us-central1', 'us-east1', 'europe-west1', 'asia-northeast1']
52-
).length
52+
_.difference(regions, [
53+
'us-central1',
54+
'us-east1',
55+
'europe-west1',
56+
'asia-northeast1',
57+
]).length
5358
) {
5459
throw new Error(
5560
"The only valid regions are 'us-central1', 'us-east1', 'europe-west1', and 'asia-northeast1'"
@@ -80,11 +85,10 @@ export function runWith(runtimeOptions: {
8085
);
8186
}
8287
if (
83-
runtimeOptions.timeoutSeconds > 540 || runtimeOptions.timeoutSeconds < 0
88+
runtimeOptions.timeoutSeconds > 540 ||
89+
runtimeOptions.timeoutSeconds < 0
8490
) {
85-
throw new Error(
86-
"TimeoutSeconds must be between 0 and 540"
87-
);
91+
throw new Error('TimeoutSeconds must be between 0 and 540');
8892
}
8993
return new FunctionBuilder(runtimeOptions);
9094
}
@@ -131,11 +135,10 @@ export class FunctionBuilder {
131135
);
132136
}
133137
if (
134-
runtimeOptions.timeoutSeconds > 540 || runtimeOptions.timeoutSeconds < 0
138+
runtimeOptions.timeoutSeconds > 540 ||
139+
runtimeOptions.timeoutSeconds < 0
135140
) {
136-
throw new Error(
137-
"TimeoutSeconds must be between 0 and 540"
138-
);
141+
throw new Error('TimeoutSeconds must be between 0 and 540');
139142
}
140143
this.options = _.assign(this.options, runtimeOptions);
141144
return this;

src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ if (!process.env.FIREBASE_CONFIG) {
6262
'Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail'
6363
);
6464
process.env.FIREBASE_CONFIG = JSON.stringify({
65-
databaseURL: `${process.env.DATABASE_URL}` || `https://${process.env.GCLOUD_PROJECT}.firebaseio.com`,
66-
storageBucket: `${process.env.STORAGE_BUCKET_URL}` || `${process.env.GCLOUD_PROJECT}.appspot.com`,
65+
databaseURL:
66+
`${process.env.DATABASE_URL}` ||
67+
`https://${process.env.GCLOUD_PROJECT}.firebaseio.com`,
68+
storageBucket:
69+
`${process.env.STORAGE_BUCKET_URL}` ||
70+
`${process.env.GCLOUD_PROJECT}.appspot.com`,
6771
projectId: process.env.GCLOUD_PROJECT,
6872
});
6973
} else {

0 commit comments

Comments
 (0)