|
1 | 1 | #!/usr/bin/env node |
2 | 2 |
|
3 | 3 | import minimist from 'minimist' |
4 | | -import {readFile, writeFile, existsSync, lstatSync, readdirSync} from 'mz/fs' |
| 4 | +import {readFileSync, writeFileSync, existsSync, lstatSync, readdirSync} from 'fs' |
5 | 5 | import * as mkdirp from 'mkdirp' |
6 | 6 | import {glob} from 'glob' |
7 | 7 | import isGlob from 'is-glob' |
@@ -114,14 +114,14 @@ async function processDir(argIn: string, argOut: string | undefined, argv: Parti |
114 | 114 | ) |
115 | 115 | } |
116 | 116 |
|
117 | | -async function outputResult(result: string, outputPath: string | undefined): Promise<void> { |
| 117 | +function outputResult(result: string, outputPath: string | undefined): void { |
118 | 118 | if (!outputPath) { |
119 | 119 | process.stdout.write(result) |
120 | 120 | } else { |
121 | 121 | if (!isDir(dirname(outputPath))) { |
122 | 122 | mkdirp.sync(dirname(outputPath)) |
123 | 123 | } |
124 | | - return await writeFile(outputPath, result) |
| 124 | + return writeFileSync(outputPath, result) |
125 | 125 | } |
126 | 126 | } |
127 | 127 |
|
@@ -150,12 +150,12 @@ async function readInput(argIn?: string): Promise<{filename: string | null; cont |
150 | 150 | } |
151 | 151 | return { |
152 | 152 | filename: argIn, |
153 | | - contents: await readFile(resolve(process.cwd(), argIn), 'utf-8'), |
| 153 | + contents: readFileSync(resolve(process.cwd(), argIn), 'utf-8'), |
154 | 154 | } |
155 | 155 | } |
156 | 156 |
|
157 | 157 | async function readStream(stream: NodeJS.ReadStream): Promise<string> { |
158 | | - const chunks = [] |
| 158 | + const chunks: Uint8Array[] = [] |
159 | 159 | for await (const chunk of stream) chunks.push(chunk) |
160 | 160 | return Buffer.concat(chunks).toString('utf8') |
161 | 161 | } |
|
0 commit comments