Skip to content

Commit

Permalink
Fix error handling for http (#242)
Browse files Browse the repository at this point in the history
The reject handler were always called no matter if there was an
error or not.
  • Loading branch information
BridgeAR authored and fkling committed Mar 7, 2018
1 parent a85f52b commit ccab1fc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,17 +157,19 @@ function run(transformFile, paths, options) {
})
.on('end', () => {
temp.open('jscodeshift', (err, info) => {
reject(err);
fs.write(info.fd, contents);
fs.close(info.fd, function(err) {
reject(err);
transform(info.path).then(resolve, reject);
if (err) return reject(err);
fs.write(info.fd, contents, function (err) {
if (err) return reject(err);
fs.close(info.fd, function(err) {
if (err) return reject(err);
transform(info.path).then(resolve, reject);
});
});
});
})
})
.on('error', (e) => {
reject(e.message);
reject(e);
});
});
} else if (!fs.existsSync(transformFile)) {
Expand Down

0 comments on commit ccab1fc

Please sign in to comment.