Skip to content

Commit

Permalink
[Chore] Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
bcherny committed Apr 20, 2024
1 parent d92b06e commit 4f47952
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 25 deletions.
18 changes: 8 additions & 10 deletions package.json
Expand Up @@ -49,21 +49,19 @@
"homepage": "https://github.com/bcherny/json-schema-to-typescript#readme",
"dependencies": {
"@apidevtools/json-schema-ref-parser": "^11.5.5",
"@types/json-schema": "^7.0.11",
"@types/lodash": "^4.14.182",
"@types/prettier": "^2.6.1",
"cli-color": "^2.0.2",
"get-stdin": "^8.0.0",
"glob": "^7.1.6",
"glob-promise": "^4.2.2",
"@types/json-schema": "^7.0.15",
"@types/lodash": "^4.17.0",
"@types/prettier": "^3.0.0",
"cli-color": "^2.0.4",
"glob": "^10.3.12",
"is-glob": "^4.0.3",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"minimist": "^1.2.6",
"mkdirp": "^1.0.4",
"minimist": "^1.2.8",
"mkdirp": "^3.0.1",
"mz": "^2.7.0",
"node-fetch": "^3.3.2",
"prettier": "^2.6.2"
"prettier": "^3.2.5"
},
"devDependencies": {
"@types/cli-color": "^2.0.2",
Expand Down
13 changes: 9 additions & 4 deletions src/cli.ts
@@ -1,10 +1,9 @@
#!/usr/bin/env node

import minimist = require('minimist')
import getStdin from 'get-stdin'
import {readFile, writeFile, existsSync, lstatSync, readdirSync} from 'mz/fs'
import * as mkdirp from 'mkdirp'
import glob from 'glob-promise'
import {glob} from 'glob'
import isGlob = require('is-glob')
import {join, resolve, dirname, basename} from 'path'
import {compile, DEFAULT_OPTIONS, Options} from './index'
Expand Down Expand Up @@ -141,13 +140,19 @@ function getPaths(path: string, paths: string[] = []) {
return paths
}

function readInput(argIn?: string) {
async function readInput(argIn?: string): Promise<string> {
if (!argIn) {
return getStdin()
return readStream(process.stdin)
}
return readFile(resolve(process.cwd(), argIn), 'utf-8')
}

async function readStream(stream: NodeJS.ReadStream): Promise<string> {
const chunks = []
for await (const chunk of stream) chunks.push(chunk)
return Buffer.concat(chunks).toString('utf8')
}

function printHelp() {
const pkg = require('../../package.json')

Expand Down
2 changes: 1 addition & 1 deletion src/formatter.ts
@@ -1,7 +1,7 @@
import {format as prettify} from 'prettier'
import {Options} from './'

export function format(code: string, options: Options): string {
export async function format(code: string, options: Options): Promise<string> {
if (!options.format) {
return code
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Expand Up @@ -176,7 +176,7 @@ export async function compile(schema: JSONSchema4, name: string, options: Partia
const generated = generate(optimized, _options)
log('magenta', 'generator', time(), '✅ Result:', generated)

const formatted = format(generated, _options)
const formatted = await format(generated, _options)
log('white', 'formatter', time(), '✅ Result:', formatted)

return formatted
Expand Down
17 changes: 8 additions & 9 deletions test/__snapshots__/test/test.ts.md
Expand Up @@ -393,8 +393,7 @@ Generated by [AVA](https://avajs.dev).
*/␊
export interface UnrelatedTitle {␊
name?: string;␊
}␊
/**␊
} /**␊
* Definition has no title and produces no duplicate Interface␊
*/␊
export interface ThirdDefinition {␊
Expand Down Expand Up @@ -449495,9 +449494,10 @@ Generated by [AVA](https://avajs.dev).
* and run json-schema-to-typescript to regenerate this file.␊
*/␊
export interface ASchema {␊
f: string;␊
g?: number;␊
export interface BSchema {␊
x?: string;␊
y: number;␊
[k: string]: unknown;␊
}␊
/* eslint-disable */␊
/**␊
Expand All @@ -449506,10 +449506,9 @@ Generated by [AVA](https://avajs.dev).
* and run json-schema-to-typescript to regenerate this file.␊
*/␊
export interface BSchema {␊
x?: string;␊
y: number;␊
[k: string]: unknown;␊
export interface ASchema {␊
f: string;␊
g?: number;␊
}␊
`

Expand Down
Binary file modified test/__snapshots__/test/test.ts.snap
Binary file not shown.

0 comments on commit 4f47952

Please sign in to comment.