|
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 {existsSync, readdirSync, readFileSync, lstatSync, writeFileSync} from 'fs' |
5 | 5 | import * as mkdirp from 'mkdirp' |
6 | 6 | import {glob} from 'glob' |
7 | 7 | import isGlob from 'is-glob' |
8 | 8 | import {join, resolve, dirname} from 'path' |
9 | | -import {compile, DEFAULT_OPTIONS, Options} from './index' |
10 | | -import {pathTransform, error, parseFileAsJSONSchema, justName} from './utils' |
| 9 | +import {compile, DEFAULT_OPTIONS, Options} from './index.js' |
| 10 | +import {pathTransform, error, parseFileAsJSONSchema, justName} from './utils.js' |
11 | 11 |
|
12 | 12 | main( |
13 | 13 | minimist(process.argv.slice(2), { |
@@ -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,18 +150,18 @@ 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 | } |
162 | 162 |
|
163 | 163 | function printHelp() { |
164 | | - const pkg = require('../../package.json') |
| 164 | + const pkg = JSON.parse(readFileSync('../../package.json', 'utf8')) |
165 | 165 |
|
166 | 166 | process.stdout.write( |
167 | 167 | ` |
|
0 commit comments