Skip to content

Commit cc87adc

Browse files
committed
feat: optim error
1 parent 1eb49d0 commit cc87adc

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "appthinning",
3-
"version": "0.2.2",
3+
"version": "0.2.3",
44
"description": "Make app thinner. Help you find large files and compress png, gif, jpg, jpeg, svg files.",
55
"main": "index.js",
66
"bin": {

src/error/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class AppthinningError extends Error {
77

88
class ProjectParamError extends AppthinningError {
99
constructor() {
10-
super(1, "Project directory parameter not specified.")
10+
super(1, "Project directory does not specified.")
1111
}
1212
}
1313

@@ -47,6 +47,12 @@ class ImageOptimError extends AppthinningError {
4747
}
4848
}
4949

50+
class ImageOptimNotInstalledError extends AppthinningError {
51+
constructor() {
52+
super(8, "ImageOptim.app is not installed, you can get it from https://imageoptim.com/mac")
53+
}
54+
}
55+
5056
module.exports = {
5157
AppthinningError,
5258
ProjectParamError,
@@ -55,5 +61,6 @@ module.exports = {
5561
SvgoError,
5662
TinyPngError,
5763
TinyPngValidateError,
58-
ImageOptimError
64+
ImageOptimError,
65+
ImageOptimNotInstalledError
5966
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ middlewareCenter.handleRequest(ctx).then(function(data){
2727

2828
function commander() {
2929
program
30-
.version("0.2.2")
30+
.version("0.2.3")
3131
.option("-d, --dir <String>", "project directory.")
3232
.option(
3333
"-t, --types <String>",

src/util/imageOptim/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const colors = require("colors")
44
const nodeCmd = require("node-cmd")
55
const path = require("path")
66
const fs = require("fs-extra");
7-
const {ImageOptimError} = require("../../error")
7+
const {ImageOptimError, ImageOptimNotInstalledError} = require("../../error")
88

99
const IMAGEOPTIM_BIN_PATH = '/Applications/ImageOptim.app/Contents/MacOS/ImageOptim';
1010

@@ -31,7 +31,7 @@ function imageOptim(images) {
3131
}
3232
})
3333
} else {
34-
reject(new ImageOptimError(new Error(`ImageOptim.app is not installed (https://imageoptim.com/mac)`)))
34+
reject(new ImageOptimNotInstalledError())
3535
}
3636
})
3737
})

src/util/tinyPng/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function validate(images) {
5353
return new Promise((resolve, reject) => {
5454
tinify.validate(function(err) {
5555
if (err) {
56-
reject(new TinyPngError())
56+
reject(new TinyPngValidateError())
5757
}
5858

5959
const compressionsThisMonth = tinify.compressionCount

0 commit comments

Comments
 (0)