From 2e5eab490e206b61e4ec171a664bc1715d125549 Mon Sep 17 00:00:00 2001 From: Gary Bortosky Date: Thu, 25 Nov 2021 09:31:13 -0600 Subject: [PATCH] polyfill readFile promise see https://github.com/nodejs/node/issues/35740 --- packages/cli/src/info.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/info.ts b/packages/cli/src/info.ts index 54e9a7d..9af995d 100644 --- a/packages/cli/src/info.ts +++ b/packages/cli/src/info.ts @@ -1,4 +1,4 @@ -import { readFile } from 'fs/promises'; +import { PathOrFileDescriptor, readFile as rf } from 'fs'; import { dirname, posix } from 'path'; import { tablify } from './markdown'; import { InfoOptions } from './types'; @@ -21,6 +21,15 @@ interface PackageConfig { version: string; } +async function readFile(path: PathOrFileDescriptor): Promise { + return new Promise((resolve, reject) => { + rf(path, (e, buff) => { + if (e) reject(e); + resolve(buff); + }); + }); +} + export class Info { public constructor(private options: InfoOptions) { if (this.options.verbose) {