Skip to content

Commit

Permalink
fix node v6 warnings on jsdoc error
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Sep 20, 2016
1 parent 9270c37 commit 8240ddf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
13 changes: 9 additions & 4 deletions es5/jsdoc-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons

var arrayify = require('array-back');
var path = require('path');
var promiseFinally = require('promise.prototype.finally');
promiseFinally.shim();

var JsdocCommand = function () {
function JsdocCommand(options, cache) {
Expand Down Expand Up @@ -42,14 +44,17 @@ var JsdocCommand = function () {
var err = this.validate();
this.output = this.getOutput(err);
if (this.output instanceof Promise) {
var promiseFinally = require('promise.prototype.finally');
promiseFinally(this.output).then(function () {
_this.postExecute();
return this.output.then(function (result) {
return result;
}).catch(function (err) {
throw err;
}).finally(function () {
return _this.postExecute();
});
} else {
this.postExecute();
return this.output;
}
return this.output;
}
}, {
key: 'preExecute',
Expand Down
4 changes: 3 additions & 1 deletion es5/temp-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ var TempFile = function () {
_createClass(TempFile, [{
key: 'delete',
value: function _delete() {
fs.unlinkSync(this.path);
try {
fs.unlinkSync(this.path);
} catch (err) {}
}
}]);

Expand Down
16 changes: 11 additions & 5 deletions lib/jsdoc-command.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict'
const arrayify = require('array-back')
const path = require('path')
const promiseFinally = require('promise.prototype.finally')
promiseFinally.shim()

/**
* @module jsdoc-command
Expand Down Expand Up @@ -49,14 +51,18 @@ class JsdocCommand {
const err = this.validate()
this.output = this.getOutput(err)
if (this.output instanceof Promise) {
const promiseFinally = require('promise.prototype.finally')
promiseFinally(this.output).then(() => {
this.postExecute()
})
return this.output
.then(result => {
return result
})
.catch(err => {
throw err
})
.finally(() => this.postExecute())
} else {
this.postExecute()
return this.output
}
return this.output
}

/**
Expand Down
6 changes: 5 additions & 1 deletion lib/temp-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ class TempFile {
fs.writeFileSync(this.path, source)
}
delete () {
fs.unlinkSync(this.path)
try {
fs.unlinkSync(this.path)
} catch (err) {
// already deleted
}
}
}

Expand Down

0 comments on commit 8240ddf

Please sign in to comment.