File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -44,11 +44,23 @@ const options = yargs
4444 alias : 'canvasWidth' ,
4545 describe : 'Width of canvas for final output' ,
4646 type : 'number' ,
47+ coerce : ( value ) => {
48+ if ( value !== undefined && value < 1 ) {
49+ throw new Error ( 'canvasWidth should not be lower than 1' ) ;
50+ }
51+ return Math . round ( value ) ;
52+ } ,
4753 } )
4854 . option ( 'g' , {
4955 alias : 'canvasHeight' ,
5056 describe : 'Height of canvas for final output' ,
5157 type : 'number' ,
58+ coerce : ( value ) => {
59+ if ( value !== undefined && value < 1 ) {
60+ throw new Error ( 'canvasHeight should not be lower than 1' ) ;
61+ }
62+ return Math . round ( value ) ;
63+ } ,
5264 } ) . argv ;
5365if ( options . filename ) {
5466 // Process a single image
Original file line number Diff line number Diff line change @@ -45,11 +45,23 @@ const options = yargs
4545 alias : 'canvasWidth' ,
4646 describe : 'Width of canvas for final output' ,
4747 type : 'number' ,
48+ coerce : ( value ) => {
49+ if ( value !== undefined && value < 1 ) {
50+ throw new Error ( 'canvasWidth should not be lower than 1' ) ;
51+ }
52+ return Math . round ( value ) ;
53+ } ,
4854 } )
4955 . option ( 'g' , {
5056 alias : 'canvasHeight' ,
5157 describe : 'Height of canvas for final output' ,
5258 type : 'number' ,
59+ coerce : ( value ) => {
60+ if ( value !== undefined && value < 1 ) {
61+ throw new Error ( 'canvasHeight should not be lower than 1' ) ;
62+ }
63+ return Math . round ( value ) ;
64+ } ,
5365 } ) . argv as unknown as Options ;
5466
5567if ( options . filename ) {
You can’t perform that action at this time.
0 commit comments