diff --git a/src/common/runtime/cmdline.ts b/src/common/runtime/cmdline.ts index 4513621f12d..004e42b30d8 100644 --- a/src/common/runtime/cmdline.ts +++ b/src/common/runtime/cmdline.ts @@ -1,7 +1,5 @@ /* eslint-disable no-console, n/no-restricted-import */ -import * as fs from 'fs'; - import { dataCache } from '../framework/data_cache.js'; import { getResourcePath, setBaseResourcePath } from '../framework/resources.js'; import { globalTestConfig } from '../framework/test_config.js'; @@ -152,13 +150,16 @@ Did you remember to build with code coverage instrumentation enabled?` dataCache.setStore({ load: (path: string) => { return new Promise((resolve, reject) => { - fs.readFile(getResourcePath(`cache/${path}`), (err, data) => { - if (err !== null) { - reject(err.message); - } else { - resolve(data); + sys.readFile( + getResourcePath(`cache/${path}`), + (err: { message: string }, data: Uint8Array) => { + if (err !== null) { + reject(err.message); + } else { + resolve(data); + } } - }); + ); }); }, }); diff --git a/src/common/runtime/helper/sys.ts b/src/common/runtime/helper/sys.ts index eba78554d59..cb325dda80e 100644 --- a/src/common/runtime/helper/sys.ts +++ b/src/common/runtime/helper/sys.ts @@ -3,10 +3,11 @@ function node() { /* eslint-disable-next-line n/no-restricted-require */ - const { existsSync } = require('fs'); + const { readFile, existsSync } = require('fs'); return { type: 'node', + readFile, existsSync, args: process.argv.slice(2), cwd: () => process.cwd(), @@ -16,6 +17,10 @@ function node() { declare global { namespace Deno { + function readFile( + path: string, + callback?: (error: unknown, data: string) => void + ): Promise; function readFileSync(path: string): Uint8Array; const args: string[]; const cwd: () => string; @@ -36,6 +41,7 @@ function deno() { return { type: 'deno', existsSync, + readFile: Deno.readFile, args: Deno.args, cwd: Deno.cwd, exit: Deno.exit,