Skip to content

Commit

Permalink
[Chore] Remove dependency on mz
Browse files Browse the repository at this point in the history
  • Loading branch information
bcherny committed Jun 20, 2024
1 parent fcb6f73 commit 31993de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 50 deletions.
48 changes: 5 additions & 43 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -114,14 +114,14 @@ async function processDir(argIn: string, argOut: string | undefined, argv: Parti
)
}

async function outputResult(result: string, outputPath: string | undefined): Promise<void> {
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)
}
}

Expand Down Expand Up @@ -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<string> {
const chunks = []
const chunks: Uint8Array[] = []
for await (const chunk of stream) chunks.push(chunk)
return Buffer.concat(chunks).toString('utf8')
}
Expand Down

0 comments on commit 31993de

Please sign in to comment.