Skip to content
This repository was archived by the owner on Jan 10, 2019. It is now read-only.

Commit 4c2caa4

Browse files
committed
improved Promise check
1 parent 3ac0017 commit 4c2caa4

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vs-script-commands",
33
"displayName": "Script Commands",
44
"description": "Adds additional commands to Visual Studio Code that uses scripts (JavaScript) for execution.",
5-
"version": "2.0.1",
5+
"version": "2.1.0",
66
"publisher": "mkloubert",
77
"engines": {
88
"vscode": "^1.5.0"

src/controller.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -868,23 +868,11 @@ export class ScriptCommandController extends Events.EventEmitter implements vsco
868868
});
869869

870870
let result = cmdModule.execute(args);
871-
if ('object' === typeof result) {
872-
if ('function' === typeof result['then']) {
873-
// seems to be a promise
874-
875-
result.then((r) => {
876-
completed(null, r);
877-
}, (err) => {
878-
completed(err);
879-
});
880-
}
881-
else {
882-
completed(null, result); // DOES NOT seem to be a promise
883-
}
884-
}
885-
else {
886-
completed(null, result); // no object
887-
}
871+
Promise.resolve(result).then((r) => {
872+
completed(null, r);
873+
}).catch((err) => {
874+
completed(err);
875+
});
888876
}
889877
else {
890878
completed(null); // no execute() function found

0 commit comments

Comments
 (0)