diff --git a/src/index.ts b/src/index.ts index 0a36e32..fc5dbb6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,5 @@ +import {Stream} from 'stream'; + /** * Copyright 2014 Google Inc. All Rights Reserved. * @@ -30,7 +32,7 @@ export function replaceProjectIdToken(value: any, projectId: string): any { } if (value !== null && typeof value === 'object' && - !(value instanceof Buffer) && + !(value instanceof Buffer) && !(value instanceof Stream) && typeof value.hasOwnProperty === 'function') { for (const opt in value) { if (value.hasOwnProperty(opt)) { diff --git a/test/index.ts b/test/index.ts index 914cb62..1af80e5 100644 --- a/test/index.ts +++ b/test/index.ts @@ -15,6 +15,7 @@ */ import * as assert from 'assert'; +import * as stream from 'stream'; import {replaceProjectIdToken} from '../src'; describe('projectId placeholder', () => { @@ -110,4 +111,13 @@ describe('projectId placeholder', () => { }, replaced); }); + + it('should not inject projectId into stream', () => { + // tslint:disable-next-line: no-any + const transform = new stream.Transform() as any; + transform.prop = 'A {{projectId}} Z'; + + const replaced = replaceProjectIdToken(transform, PROJECT_ID); + assert.deepEqual(transform.prop, replaced.prop); + }); });