Skip to content

Commit

Permalink
Merge e6d93eb into 8c7ce97
Browse files Browse the repository at this point in the history
  • Loading branch information
TerribleDev committed Feb 7, 2018
2 parents 8c7ce97 + e6d93eb commit 23cef5c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/declarations/child-process-promise.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
declare module "child-process-promise";
declare module "child-process-promise" {
export function spawn(command: string, arguments: string[], options: any): Promise<any>;
}
11 changes: 9 additions & 2 deletions src/shelly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function shelly(command: string, noun: string|string[], args: any
throw new PluginError(PLUGIN_NAME, "Arguments has to be an array");
}
// Creating a stream through which each file will pass
return through.obj((file, enc, cb) => {
return through.obj(function(this: Transform, file, enc, cb) {
if (!file || !file.path) {
// return empty file
return cb(null, file);
Expand All @@ -45,7 +45,14 @@ export default function shelly(command: string, noun: string|string[], args: any
}
cp.spawn(command, calculatedArgs, options)
.then((a: any) => cb(null, file))
.catch((ex: any) => cb(ex, file));
.catch((ex: Error) => {
let pluginError = new PluginError(PLUGIN_NAME, `failed to ${noun}`);
this.emit("error", pluginError);
cb(pluginError, file);
})
// emit will trick node in thinking we have unhandled promise rejections
// tslint:disable-next-line:no-empty
.catch((ex) => { });

});

Expand Down

0 comments on commit 23cef5c

Please sign in to comment.