File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ export const bug = (err: Error): void => {
1616 process . exit ( 1 ) ;
1717} ;
1818
19+ export const panic = ( value : string ) : void => {
20+ console . log ( color . red ( '! %s' ) , value ) ;
21+ process . exit ( 1 ) ;
22+ } ;
23+
1924export const result = (
2025 label : string = 'TOTAL' ,
2126 prettySizeBefore : string ,
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { pathExists } from 'fs-extra';
22import { AppRunner , IOptions } from '.' ;
33import { IMAGEALPHA , IMAGEALPHA_URL , PNGQUANT_BIN_PATH } from './constants' ;
44import { isSupported } from './is-supported' ;
5- import { info , verbose , warning } from './log' ;
5+ import { info , panic , verbose } from './log' ;
66import { pngquant } from './pngquant' ;
77
88export const runImageAlpha : AppRunner = async ( options : IOptions ) => {
@@ -11,7 +11,7 @@ export const runImageAlpha: AppRunner = async (options: IOptions) => {
1111 . map ( ( file ) => file . tmp )
1212 . filter ( isSupported ( IMAGEALPHA . supports ) ) ;
1313 if ( ! ( await pathExists ( PNGQUANT_BIN_PATH ) ) ) {
14- return warning ( `ImageAlpha.app is not installed (${ IMAGEALPHA_URL } )` ) ;
14+ return panic ( `ImageAlpha.app is not installed (${ IMAGEALPHA_URL } )` ) ;
1515 }
1616 await pngquant ( pngFilePaths , options ) ;
1717 verbose ( `${ IMAGEALPHA . name } has finished` ) ;
Original file line number Diff line number Diff line change @@ -2,12 +2,12 @@ import * as execa from 'execa';
22import { pathExists } from 'fs-extra' ;
33import { AppRunner } from '.' ;
44import { IMAGEOPTIM , IMAGEOPTIM_BIN_PATH , IMAGEOPTIM_URL } from './constants' ;
5- import { info , verbose , warning } from './log' ;
5+ import { info , panic , verbose } from './log' ;
66
77export const runImageOptim : AppRunner = async ( options ) => {
88 info ( `Running ${ IMAGEOPTIM . name } ...` ) ;
99 if ( ! ( await pathExists ( IMAGEOPTIM_BIN_PATH ) ) ) {
10- return warning ( `ImageOptim.app is not installed (${ IMAGEOPTIM_URL } )` ) ;
10+ return panic ( `ImageOptim.app is not installed (${ IMAGEOPTIM_URL } )` ) ;
1111 }
1212 await execa ( IMAGEOPTIM_BIN_PATH , [ options . tmpDir ] ) ;
1313 verbose ( `${ IMAGEOPTIM . name } has finished` ) ;
Original file line number Diff line number Diff line change 55 runJpegMini as startJpegMini ,
66 supportsAssistiveDevices
77} from './applescript' ;
8- import { ASSISTIVE_DEVICES_URL , HOMEPAGE_URL , JPEG_MINI_URL } from './constants' ;
9- import { info , verbose , warning } from './log' ;
8+ import { ASSISTIVE_DEVICES_URL , JPEG_MINI_URL } from './constants' ;
9+ import { info , panic , verbose } from './log' ;
1010
1111export const runJpegMini : AppRunner = async ( options ) => {
1212 verbose ( 'Locating JPEGmini installation' ) ;
@@ -18,11 +18,11 @@ export const runJpegMini: AppRunner = async (options) => {
1818 const [ app , canAutomate ] = await Promise . all ( [ jpegMini , assistiveDeviceSupport ] ) ;
1919
2020 if ( ! app ) {
21- return warning ( `JPEGmini is not installed (${ JPEG_MINI_URL } )` ) ;
21+ return panic ( `JPEGmini is not installed (${ JPEG_MINI_URL } )` ) ;
2222 }
2323
2424 if ( ! canAutomate ) {
25- return warning ( `Support for assistive devices needed, see ${ ASSISTIVE_DEVICES_URL } ` ) ;
25+ return panic ( `Support for assistive devices needed, see ${ ASSISTIVE_DEVICES_URL } ` ) ;
2626 }
2727
2828 info ( `Running ${ app . name } ...` ) ;
You can’t perform that action at this time.
0 commit comments