Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Promise issues where callback was being called twice #15

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/LoaderRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ function runSyncOrAsync(fn, context, args, callback) {
if(result === undefined)
return callback();
if(result && typeof result === "object" && typeof result.then === "function") {
return result.catch(callback).then(function(r) {
return result.then(function(r) {
callback(null, r);
});
}, callback);
}
return callback(null, result);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/loadLoader.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module.exports = function loadLoader(loader, callback) {
if(typeof System === "object" && typeof System.import === "function") {
System.import(loader.path).catch(callback).then(function(module) {
System.import(loader.path).then(function(module) {
loader.normal = typeof module === "function" ? module : module.default;
loader.pitch = module.pitch;
loader.raw = module.raw;
if(typeof loader.normal !== "function" && typeof loader.pitch !== "function")
throw new Error("Module '" + loader.path + "' is not a loader (must have normal or pitch function)");
callback();
});
}, callback);
} else {
try {
var module = require(loader.path);
Expand Down