From 5f0ca5999814741c7573f567d446fabff33461f3 Mon Sep 17 00:00:00 2001 From: Diana Tkachenko Date: Wed, 30 Jan 2019 11:49:30 -0800 Subject: [PATCH] Prettier changes --- integration_test/functions/src/index.ts | 11 +++--- .../functions/src/storage-tests.ts | 3 +- spec/function-builder.spec.ts | 6 +--- spec/providers/database.spec.ts | 6 ++-- src/function-builder.ts | 35 ++++++++++--------- src/index.ts | 8 +++-- 6 files changed, 38 insertions(+), 31 deletions(-) diff --git a/integration_test/functions/src/index.ts b/integration_test/functions/src/index.ts index 56cbba7f6..76094b0a4 100644 --- a/integration_test/functions/src/index.ts +++ b/integration_test/functions/src/index.ts @@ -2,7 +2,7 @@ import * as functions from 'firebase-functions'; import * as https from 'https'; import * as admin from 'firebase-admin'; import { Request, Response } from 'express'; -import * as fs from 'fs' +import * as fs from 'fs'; import * as PubSub from '@google-cloud/pubsub'; const pubsub = PubSub(); @@ -59,7 +59,7 @@ export const integrationTests: any = functions .ref() .push().key; console.log('testId is: ', testId); - fs.writeFile('/tmp/' + testId + '.txt', 'test', ()=> {}); + fs.writeFile('/tmp/' + testId + '.txt', 'test', () => {}); return Promise.all([ // A database write to trigger the Firebase Realtime Database tests. admin @@ -93,7 +93,7 @@ export const integrationTests: any = functions admin.credential .applicationDefault() .getAccessToken() - .then((accessToken) => { + .then(accessToken => { const options = { hostname: 'firebaseremoteconfig.googleapis.com', path: `/v1/projects/${firebaseConfig.projectId}/remoteConfig`, @@ -110,7 +110,10 @@ export const integrationTests: any = functions request.end(); }), // A storage upload to trigger the Storage tests - admin.storage().bucket().upload('/tmp/' + testId + '.txt'), + admin + .storage() + .bucket() + .upload('/tmp/' + testId + '.txt'), // Invoke a callable HTTPS trigger. callHttpsTrigger('callableTests', { foo: 'bar', testId }), ]) diff --git a/integration_test/functions/src/storage-tests.ts b/integration_test/functions/src/storage-tests.ts index 3f3c4e997..7ced40fc9 100644 --- a/integration_test/functions/src/storage-tests.ts +++ b/integration_test/functions/src/storage-tests.ts @@ -7,7 +7,8 @@ export const storageTests: any = functions .runWith({ timeoutSeconds: 540, }) - .storage.bucket().object() + .storage.bucket() + .object() .onFinalize((s, c) => { const testId = s.name.split('.')[0]; return new TestSuite('storage object finalize') diff --git a/spec/function-builder.spec.ts b/spec/function-builder.spec.ts index 118525c0f..6472720bb 100644 --- a/spec/function-builder.spec.ts +++ b/spec/function-builder.spec.ts @@ -48,10 +48,7 @@ describe('FunctionBuilder', () => { .auth.user() .onCreate(user => user); - expect(fn.__trigger.regions).to.deep.equal([ - 'us-east1', - 'us-central1', - ]); + expect(fn.__trigger.regions).to.deep.equal(['us-east1', 'us-central1']); }); it('should allow runtime options to be set', () => { @@ -158,5 +155,4 @@ describe('FunctionBuilder', () => { } as any); }).to.throw(Error); }); - }); diff --git a/spec/providers/database.spec.ts b/spec/providers/database.spec.ts index 95db92d46..47a068e85 100644 --- a/spec/providers/database.spec.ts +++ b/spec/providers/database.spec.ts @@ -251,17 +251,17 @@ describe('Database Functions', () => { return database.resourceToInstanceAndPath( 'projects/_/instances/a.bad.name/refs/bar' ); - }).to.throw(Error) + }).to.throw(Error); expect(() => { return database.resourceToInstanceAndPath( 'projects/_/instances/a_different_bad_name/refs/bar' ); - }).to.throw(Error) + }).to.throw(Error); expect(() => { return database.resourceToInstanceAndPath( 'projects/_/instances/BAD!!!!/refs/bar' ); - }).to.throw(Error) + }).to.throw(Error); }); }); diff --git a/src/function-builder.ts b/src/function-builder.ts index e2a52cf42..255c751cc 100644 --- a/src/function-builder.ts +++ b/src/function-builder.ts @@ -32,7 +32,12 @@ import * as https from './providers/https'; import * as pubsub from './providers/pubsub'; import * as remoteConfig from './providers/remoteConfig'; import * as storage from './providers/storage'; -import { CloudFunction, EventContext, Runnable, TriggerAnnotated } from './cloud-functions'; +import { + CloudFunction, + EventContext, + Runnable, + TriggerAnnotated, +} from './cloud-functions'; /** * Configure the regions that the function is deployed to. @@ -41,15 +46,15 @@ import { CloudFunction, EventContext, Runnable, TriggerAnnotated } from './cloud */ export function region(...regions: string[]) { if (!regions.length) { - throw new Error( - "You must specify at least one region" - ); + throw new Error('You must specify at least one region'); } if ( - _.difference( - regions, - ['us-central1', 'us-east1', 'europe-west1', 'asia-northeast1'] - ).length + _.difference(regions, [ + 'us-central1', + 'us-east1', + 'europe-west1', + 'asia-northeast1', + ]).length ) { throw new Error( "The only valid regions are 'us-central1', 'us-east1', 'europe-west1', and 'asia-northeast1'" @@ -80,11 +85,10 @@ export function runWith(runtimeOptions: { ); } if ( - runtimeOptions.timeoutSeconds > 540 || runtimeOptions.timeoutSeconds < 0 + runtimeOptions.timeoutSeconds > 540 || + runtimeOptions.timeoutSeconds < 0 ) { - throw new Error( - "TimeoutSeconds must be between 0 and 540" - ); + throw new Error('TimeoutSeconds must be between 0 and 540'); } return new FunctionBuilder(runtimeOptions); } @@ -131,11 +135,10 @@ export class FunctionBuilder { ); } if ( - runtimeOptions.timeoutSeconds > 540 || runtimeOptions.timeoutSeconds < 0 + runtimeOptions.timeoutSeconds > 540 || + runtimeOptions.timeoutSeconds < 0 ) { - throw new Error( - "TimeoutSeconds must be between 0 and 540" - ); + throw new Error('TimeoutSeconds must be between 0 and 540'); } this.options = _.assign(this.options, runtimeOptions); return this; diff --git a/src/index.ts b/src/index.ts index 4b70693dd..1e60950ca 100644 --- a/src/index.ts +++ b/src/index.ts @@ -62,8 +62,12 @@ if (!process.env.FIREBASE_CONFIG) { 'Warning, estimating Firebase Config based on GCLOUD_PROJECT. Initializing firebase-admin may fail' ); process.env.FIREBASE_CONFIG = JSON.stringify({ - databaseURL: `${process.env.DATABASE_URL}` || `https://${process.env.GCLOUD_PROJECT}.firebaseio.com`, - storageBucket: `${process.env.STORAGE_BUCKET_URL}` || `${process.env.GCLOUD_PROJECT}.appspot.com`, + databaseURL: + `${process.env.DATABASE_URL}` || + `https://${process.env.GCLOUD_PROJECT}.firebaseio.com`, + storageBucket: + `${process.env.STORAGE_BUCKET_URL}` || + `${process.env.GCLOUD_PROJECT}.appspot.com`, projectId: process.env.GCLOUD_PROJECT, }); } else {