From 31993def993b610ba238d3024260129e31ddc371 Mon Sep 17 00:00:00 2001 From: Boris Cherny Date: Thu, 20 Jun 2024 15:26:53 +0200 Subject: [PATCH] [Chore] Remove dependency on mz --- package-lock.json | 48 +++++------------------------------------------ package.json | 2 -- src/cli.ts | 10 +++++----- 3 files changed, 10 insertions(+), 50 deletions(-) diff --git a/package-lock.json b/package-lock.json index 268c0365..8713126e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "json-schema-to-typescript", - "version": "14.0.2", + "version": "14.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "json-schema-to-typescript", - "version": "14.0.2", + "version": "14.0.5", "license": "MIT", "dependencies": { "@apidevtools/json-schema-ref-parser": "^11.5.5", @@ -19,7 +19,6 @@ "lodash": "^4.17.21", "minimist": "^1.2.8", "mkdirp": "^3.0.1", - "mz": "^2.7.0", "node-fetch": "^3.3.2", "prettier": "^3.2.5" }, @@ -32,7 +31,6 @@ "@types/js-yaml": "^4.0.9", "@types/minimist": "^1.2.5", "@types/mkdirp": "^2.0.0", - "@types/mz": "^2.7.8", "@types/node": "^20.12.7", "@types/rimraf": "^4.0.5", "@typescript-eslint/eslint-plugin": "^7.7.0", @@ -508,15 +506,6 @@ "mkdirp": "*" } }, - "node_modules/@types/mz": { - "version": "2.7.8", - "resolved": "https://registry.npmjs.org/@types/mz/-/mz-2.7.8.tgz", - "integrity": "sha512-mGLNqqwt8yu4pDw9rEphAiyWnEdok0GzOGrwi5EiTuDFxw7H3ZaEI4ASFKq4HaZtemtjQ8MkcmtWcrU4V0WkIw==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/node": { "version": "20.12.8", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.8.tgz", @@ -963,7 +952,8 @@ "node_modules/any-promise": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==" + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true }, "node_modules/ap": { "version": "0.2.0", @@ -4488,16 +4478,6 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "node_modules/mz": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", - "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", - "dependencies": { - "any-promise": "^1.0.0", - "object-assign": "^4.0.1", - "thenify-all": "^1.0.0" - } - }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -4595,6 +4575,7 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, "engines": { "node": ">=0.10.0" } @@ -6032,25 +6013,6 @@ "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, - "node_modules/thenify": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", - "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", - "dependencies": { - "any-promise": "^1.0.0" - } - }, - "node_modules/thenify-all": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", - "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", - "dependencies": { - "thenify": ">= 3.1.0 < 4" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", diff --git a/package.json b/package.json index 6e4e6e6f..4d699d69 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "lodash": "^4.17.21", "minimist": "^1.2.8", "mkdirp": "^3.0.1", - "mz": "^2.7.0", "node-fetch": "^3.3.2", "prettier": "^3.2.5" }, @@ -68,7 +67,6 @@ "@types/js-yaml": "^4.0.9", "@types/minimist": "^1.2.5", "@types/mkdirp": "^2.0.0", - "@types/mz": "^2.7.8", "@types/node": "^20.12.7", "@types/rimraf": "^4.0.5", "@typescript-eslint/eslint-plugin": "^7.7.0", diff --git a/src/cli.ts b/src/cli.ts index 217de215..f8d2dfb2 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -1,7 +1,7 @@ #!/usr/bin/env node import minimist from 'minimist' -import {readFile, writeFile, existsSync, lstatSync, readdirSync} from 'mz/fs' +import {readFileSync, writeFileSync, existsSync, lstatSync, readdirSync} from 'fs' import * as mkdirp from 'mkdirp' import {glob} from 'glob' import isGlob from 'is-glob' @@ -114,14 +114,14 @@ async function processDir(argIn: string, argOut: string | undefined, argv: Parti ) } -async function outputResult(result: string, outputPath: string | undefined): Promise { +function outputResult(result: string, outputPath: string | undefined): void { if (!outputPath) { process.stdout.write(result) } else { if (!isDir(dirname(outputPath))) { mkdirp.sync(dirname(outputPath)) } - return await writeFile(outputPath, result) + return writeFileSync(outputPath, result) } } @@ -150,12 +150,12 @@ async function readInput(argIn?: string): Promise<{filename: string | null; cont } return { filename: argIn, - contents: await readFile(resolve(process.cwd(), argIn), 'utf-8'), + contents: readFileSync(resolve(process.cwd(), argIn), 'utf-8'), } } async function readStream(stream: NodeJS.ReadStream): Promise { - const chunks = [] + const chunks: Uint8Array[] = [] for await (const chunk of stream) chunks.push(chunk) return Buffer.concat(chunks).toString('utf8') }