-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): show warning when ImageOptim.app is not installed
- Loading branch information
1 parent
24c4e37
commit 44f3055
Showing
4 changed files
with
21 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import { pathExists } from 'fs-extra'; | ||
import { AppRunner, IOptions } from '.'; | ||
import { IMAGEALPHA } from './constants'; | ||
import { IMAGEALPHA, IMAGEALPHA_URL, PNGQUANT_BIN_PATH } from './constants'; | ||
import { isSupported } from './is-supported'; | ||
import { info, verbose } from './log'; | ||
import { info, verbose, warning } from './log'; | ||
import { pngquant } from './pngquant'; | ||
|
||
export const runImageAlpha: AppRunner = async (options: IOptions) => { | ||
info(`Running ${IMAGEALPHA.name}...`); | ||
const pngFilePaths = options.files.supported | ||
.map((file) => file.tmp) | ||
.filter(isSupported(IMAGEALPHA.supports)); | ||
if (!(await pathExists(PNGQUANT_BIN_PATH))) { | ||
return warning(`ImageAlpha.app is not installed (${IMAGEALPHA_URL})`); | ||
} | ||
await pngquant(pngFilePaths, options); | ||
verbose(`${IMAGEALPHA.name} has finished`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
import { stdout } from 'execa'; | ||
import { pathExists } from 'fs-extra'; | ||
import { AppRunner } from '.'; | ||
import { IMAGEOPTIM, IMAGEOPTIM_BIN_PATH } from './constants'; | ||
import { info, verbose } from './log'; | ||
import { IMAGEOPTIM, IMAGEOPTIM_BIN_PATH, IMAGEOPTIM_URL } from './constants'; | ||
import { info, verbose, warning } from './log'; | ||
|
||
export const runImageOptim: AppRunner = async (options) => { | ||
info(`Running ${IMAGEOPTIM.name}...`); | ||
if (!(await pathExists(IMAGEOPTIM_BIN_PATH))) { | ||
return warning(`ImageOptim.app is not installed (${IMAGEOPTIM_URL})`); | ||
} | ||
await stdout(IMAGEOPTIM_BIN_PATH, [options.tmpDir]); | ||
verbose(`${IMAGEOPTIM.name} has finished`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters