Skip to content

Commit

Permalink
Tweak cli.js output color and format
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperupcall committed Sep 24, 2024
1 parent 67741b9 commit c4db7d8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ function printErrorAndExit(error, messages, extraText) {
}

console.warn('---')
process.stderr.write(error instanceof Error ? error?.stack ?? '' : '')
process.stderr.write(error instanceof Error ? (error?.stack ?? '') : '')
process.stderr.write('\n')
process.exit(1)
}
Expand Down Expand Up @@ -580,6 +580,7 @@ async function taskLint() {
}

async function taskCheck() {
console.info(`===== VALIDATE PRECONDITIONS =====`)
await assertFileSystemIsValid()

// Check catalog.json.
Expand All @@ -606,6 +607,7 @@ async function taskCheck() {
assertSchemaValidationJsonHasValidSkipTest()

// Run pre-checks (checks before JSON Schema validation) on all files
console.info(`===== VALIDATE SCHEMAS =====`)
const spinner = ora().start()
await forEachFile({
async onSchemaFile(schema) {
Expand Down Expand Up @@ -707,6 +709,7 @@ async function taskCheck() {
console.info(`✔️ Schemas: All Ajv validation tests succeeded`)

// Print information.
console.info(`===== REPORT =====`)
await printSimpleStatistics()
await printCountSchemaVersions()
}
Expand Down Expand Up @@ -1483,16 +1486,18 @@ EXAMPLES:
node ./cli.js check
node ./cli.js check --SchemaName=schema-catalog.json
node ./cli.js check-strict --SchemaName=schema-catalog.json
`
`

if (!argv._[0]) {
console.error(helpMenu)
console.error(`${chalk.red('Error:')} No argument given`)
process.stderr.write(helpMenu + '\n')
process.stderr.write(`${chalk.red('Error:')} No argument given` + '\n')
process.exit(1)
}
if (argv._[1]) {
console.error(helpMenu)
console.error(`${chalk.red('Error:')} Too many arguments given`)
process.stderr.write(helpMenu + '\n')
process.stderr.write(
`${chalk.red('Error:')} Too many arguments given` + '\n',
)
process.exit(1)
}
if (argv.help) {
Expand Down

0 comments on commit c4db7d8

Please sign in to comment.