|
1 | 1 | #!/usr/bin/env node
|
2 | 2 | import fs from 'fs';
|
3 | 3 | import path from 'path';
|
| 4 | +import * as url from 'url'; |
4 | 5 |
|
5 |
| -import c from 'ansi-colors'; |
6 |
| -import glob from 'fast-glob'; |
| 6 | +import { bold, red, green, dim } from 'ansi-colors'; |
| 7 | +import { glob } from 'fast-glob'; |
7 | 8 | // eslint-disable-next-line import/order -- what the actual heck, this rule bounces
|
8 | 9 | import parser from 'yargs-parser';
|
9 | 10 |
|
10 | 11 | import type { OpenAPITSOptions } from 'openapi-typescript';
|
11 | 12 |
|
12 | 13 | import { generate } from '../index.js';
|
13 | 14 |
|
| 15 | +const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); |
| 16 | + |
14 | 17 | /** print error message */
|
15 | 18 | export function error(msg: string) {
|
16 |
| - console.error(c.red(` ✘ ${msg}`)); // eslint-disable-line no-console |
| 19 | + console.error(red(` ✘ ${msg}`)); // eslint-disable-line no-console |
17 | 20 | }
|
18 | 21 |
|
19 | 22 | const HELP = `Usage
|
@@ -136,9 +139,7 @@ async function generateSchema(pathToSpec: string | typeof process.stdin) {
|
136 | 139 | const timeEnd = process.hrtime(timeStart);
|
137 | 140 | const time = timeEnd[0] + Math.round(timeEnd[1] / 1e6);
|
138 | 141 | console.log(
|
139 |
| - `🚀 ${c.green(`${pathToSpec} → ${c.bold(outputFilePath.toString())}`)} ${c.dim( |
140 |
| - `[${time}ms]`, |
141 |
| - )}`, |
| 142 | + `🚀 ${green(`${pathToSpec} → ${bold(outputFilePath.toString())}`)} ${dim(`[${time}ms]`)}`, |
142 | 143 | );
|
143 | 144 | } else {
|
144 | 145 | process.stdout.write(result);
|
@@ -166,7 +167,7 @@ async function main() {
|
166 | 167 | const outputDir = new URL('.', outputFile);
|
167 | 168 |
|
168 | 169 | if (output === OUTPUT_FILE)
|
169 |
| - console.info(`✨ ${c.bold(`openapi-typescript ${packageJSON.version}`)}`); // only log if we’re NOT writing to stdout |
| 170 | + console.info(`✨ ${bold(`openapi-typescript ${packageJSON.version}`)}`); // only log if we’re NOT writing to stdout |
170 | 171 |
|
171 | 172 | const pathToSpec = flags._[0] as string;
|
172 | 173 |
|
|
0 commit comments