Skip to content

Commit 94a9c1e

Browse files
authored
fix(gulp-sharp): update return value for gulpPlugin utility method (#3)
fix(gulp-sharp): update transformer function passed to `gulpPlugin` to always return a Promise
1 parent 8e37ba6 commit 94a9c1e

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

plugins/gulp-sharp/src/utils/plugin.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,17 @@ function transformStream(transformer) {
4747
export function gulpPlugin(name, onFile) {
4848
return transformStream((file) => {
4949
if (file.isNull() || file.isDirectory()) {
50-
return file;
50+
return Promise.resolve(file);
5151
}
5252

5353
if (file.isStream()) {
54-
throw new PluginError(name, "Streaming not supported");
54+
return Promise.reject(new PluginError(name, "Streaming not supported"));
5555
}
5656

5757
try {
5858
return onFile(file);
5959
} catch (error) {
60-
throw new PluginError(name, error, {
61-
fileName: file.path,
62-
showStack: true,
63-
});
60+
return Promise.reject(new PluginError(name, error, { fileName: file.path, showStack: true }));
6461
}
6562
});
6663
}

0 commit comments

Comments
 (0)