Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions mocha/setup.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import * as chai from "chai";
import * as chaiAsPromisedModule from "chai-as-promised";
import * as nockModule from "nock";

// Normalize CommonJS exports so ts-node (Node.js 20) and Node.js 22's strip-only loader
// both receive callable modules without relying on esModuleInterop.
type ChaiPlugin = Parameters<typeof chai.use>[0];
type NockModule = typeof nockModule;

const chaiAsPromisedExport = chaiAsPromisedModule as ChaiPlugin & { default?: ChaiPlugin };
const chaiAsPromised = chaiAsPromisedExport.default ?? chaiAsPromisedExport;
const nockExport = nockModule as NockModule & { default?: NockModule };
const nock = nockExport.default ?? nockExport;
import chai from "chai";
import chaiAsPromised from "chai-as-promised";
import nock from "nock";

chai.use(chaiAsPromised);

nock.disableNetConnect();
11 changes: 2 additions & 9 deletions scripts/bin-test/mocha-setup.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import * as chai from "chai";
import * as chaiAsPromisedModule from "chai-as-promised";

// Match the runtime shim in mocha/setup.ts so bin tests work on Node.js 20 ts-node
// and Node.js 22's strip-only TypeScript loader without enabling esModuleInterop.
type ChaiPlugin = Parameters<typeof chai.use>[0];

const chaiAsPromisedExport = chaiAsPromisedModule as ChaiPlugin & { default?: ChaiPlugin };
const chaiAsPromised = chaiAsPromisedExport.default ?? chaiAsPromisedExport;
import chai from "chai";
import chaiAsPromised from "chai-as-promised";

chai.use(chaiAsPromised);
3 changes: 1 addition & 2 deletions spec/common/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
// SOFTWARE.

import { expect } from "chai";
import * as fs from "fs";
import * as process from "process";
import fs from "fs";
import * as sinon from "sinon";

import { firebaseConfig, resetCache } from "../../src/common/config";
Expand Down
6 changes: 3 additions & 3 deletions spec/fixtures/mockrequest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EventEmitter } from 'node:stream';

import * as jwt from 'jsonwebtoken';
import * as jwkToPem from 'jwk-to-pem';
import * as nock from 'nock';
import jwt from 'jsonwebtoken';
import jwkToPem from 'jwk-to-pem';
import nock from 'nock';
import * as mockJWK from '../fixtures/credential/jwk.json';
import * as mockKey from '../fixtures/credential/key.json';

Expand Down
2 changes: 1 addition & 1 deletion src/bin/firebase-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// SOFTWARE.

import * as http from "http";
import * as express from "express";
import express from "express";
import * as fs from "fs/promises";
import * as path from "path";
import { loadStack } from "../runtime/loader";
Expand Down
4 changes: 2 additions & 2 deletions src/common/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppOptions } from "firebase-admin/app";
import { readFileSync } from "fs";
import fs from "fs";
import * as path from "path";

import * as logger from "../logger";
Expand Down Expand Up @@ -29,7 +29,7 @@ export function firebaseConfig(): AppOptions | null {
// explicitly state that the user can set the env to a file:
// https://firebase.google.com/docs/admin/setup#initialize-without-parameters
if (!env.startsWith("{")) {
env = readFileSync(path.join(process.env.PWD, env)).toString("utf8");
env = fs.readFileSync(path.join(process.env.PWD, env)).toString("utf8");
}

cache = JSON.parse(env);
Expand Down
2 changes: 1 addition & 1 deletion src/common/providers/https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

import * as cors from "cors";
import cors from "cors";
import * as express from "express";
import { DecodedAppCheckToken } from "firebase-admin/app-check";

Expand Down
2 changes: 1 addition & 1 deletion src/v2/providers/https.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* @packageDocumentation
*/

import * as cors from "cors";
import cors from "cors";
import * as express from "express";
import { convertIfPresent, convertInvoker, copyIfPresent } from "../../common/encoding";
import { wrapTraceContext } from "../trace";
Expand Down
1 change: 1 addition & 0 deletions tsconfig.release.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"stripInternal": true,
"target": "es2022",
"useDefineForClassFields": false,
"esModuleInterop": true,
"typeRoots": ["./node_modules/@types"]
},
"files": [
Expand Down
Loading