This repository was archived by the owner on Dec 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88 "devDependencies" : {
99 "@sindresorhus/tsconfig" : " ^3.0.1" ,
1010 "@types/node" : " ^18.8.0" ,
11- "ava" : " ^4.3.3" ,
12- "nyc" : " ^15.1.0" ,
1311 "pkg" : " ^5.8.0" ,
14- "ts-node " : " ^10 .9.1 " ,
12+ "tsx " : " ^3 .9.0 " ,
1513 "typescript" : " ^4.8.4"
1614 },
1715 "dependencies" : {
1816 "github-version-checker" : " *" ,
17+ "pretty-error" : " ^4.0.0" ,
1918 "sade" : " ^1.8.1"
20- },
21- "ava" : {
22- "extensions" : [
23- " ts"
24- ],
25- "require" : [
26- " ts-node/register/transpile-only"
27- ]
2819 }
2920}
Original file line number Diff line number Diff line change 11import versionCheck from 'github-version-checker'
2- import { CliArguments } from './types'
2+ import PrettyError from 'pretty-error'
3+ import { CliArguments , JsonOutput } from './types'
34import { print , printError } from './util'
45
56function printPretty ( result : any , args : CliArguments ) {
@@ -11,11 +12,6 @@ function printPretty(result: any, args: CliArguments) {
1112 }
1213}
1314
14- function printJson ( result : any ) {
15- const json = JSON . stringify ( result )
16- print ( json , false )
17- }
18-
1915export default async function action ( args : CliArguments ) {
2016 try {
2117 const result = await versionCheck ( {
@@ -28,12 +24,21 @@ export default async function action(args: CliArguments) {
2824 } )
2925
3026 if ( args . json ) {
31- printJson ( result )
27+ const output : JsonOutput = {
28+ type : result === undefined ? 'notfound' : 'outdated' ,
29+ data : result
30+ }
31+ print ( JSON . stringify ( output ) , false )
3232 }
3333 else {
3434 printPretty ( result , args )
3535 }
3636 } catch ( error : any ) {
37- printError ( error . message )
37+ if ( args . verbose ) {
38+ printError ( new PrettyError ( ) . render ( error ) )
39+ }
40+ else {
41+ printError ( error . message )
42+ }
3843 }
3944}
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ program
1212 . option ( '--no-pre-releases' , 'Excludes pre-releases.' , false )
1313 . option ( '--token' , 'A PAT to use.' )
1414 . option ( '--json' , 'Outputs the raw result data as JSON.' , false )
15+ . option ( '--verbose' , 'Enables verbose logging.' , false )
1516 . action ( action )
1617
1718program . parse ( process . argv )
Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ export interface CliArguments {
66 'no-pre-releases' : boolean
77 token ?: string
88 json : boolean
9+ verbose : boolean
910}
Original file line number Diff line number Diff line change @@ -10,5 +10,5 @@ export function print(data: any, newline = true) {
1010}
1111
1212export function printError ( data : any , newline = true ) {
13- write ( process . stderr , data , newline )
13+ write ( process . stdout , data , newline )
1414}
You can’t perform that action at this time.
0 commit comments