Fix #2815 nodejs 0.11 compatibility is Absolute (#2816)

This commit is contained in:
Antoine Bluchet 2017-04-06 23:52:50 +02:00 committed by vmarchaud
parent 1577535be0
commit f98ded6b71

View File

@ -833,17 +833,27 @@ API.prototype._startJson = function(file, opts, action, pipe, cb) {
var apps_info = [];
var that = this;
if (typeof(cb) === 'undefined' && typeof(pipe) === 'function')
if (typeof(cb) === 'undefined' && typeof(pipe) === 'function') {
cb = pipe;
}
if (typeof(file) === 'object')
if (typeof(file) === 'object') {
config = file;
else if (pipe == 'pipe')
} else if (pipe === 'pipe') {
config = Common.parseConfig(file, 'pipe');
else {
} else {
var data = null;
var file_path = path.isAbsolute(file) ? file : path.join(that.cwd, file);
var isAbsolute = false
//node 0.11 compatibility #2815
if (typeof path.isAbsolute === 'function') {
isAbsolute = path.isAbsolute(file)
} else {
isAbsolute = /^\/|\\/.test(file)
}
var file_path = isAbsolute ? file : path.join(that.cwd, file);
debug('Resolved filepath %s', file_path);