2016-03-12 07:24:05 +00:00
|
|
|
/// <reference path="typings/main.d.ts" />
|
|
|
|
var plugins = require("./smartpath.plugins");
|
|
|
|
var makeAbsolute = function (localPathArg, baseArg) {
|
|
|
|
var absolutePath;
|
|
|
|
if (baseArg) {
|
|
|
|
absolutePath = plugins.path.join(baseArg, localPathArg);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
absolutePath = plugins.path.resolve(localPathArg);
|
|
|
|
}
|
|
|
|
return absolutePath;
|
|
|
|
};
|
|
|
|
var absolute = function (relativeArg, baseArg) {
|
|
|
|
if (typeof relativeArg === "string") {
|
2016-03-12 08:36:30 +00:00
|
|
|
return makeAbsolute(relativeArg, baseArg);
|
2016-03-12 07:24:05 +00:00
|
|
|
}
|
|
|
|
else if (Array.isArray(relativeArg)) {
|
|
|
|
var relativeArray = relativeArg;
|
2016-03-12 08:36:30 +00:00
|
|
|
var absoluteArray = [];
|
2016-03-12 07:24:05 +00:00
|
|
|
for (var key in relativeArray) {
|
2016-03-12 08:36:30 +00:00
|
|
|
absoluteArray.push(makeAbsolute(relativeArray[key], baseArg));
|
2016-03-12 07:24:05 +00:00
|
|
|
}
|
|
|
|
;
|
|
|
|
return absoluteArray;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
plugins.beautylog.error("smartpath.absolute() could not make sense of the input. " +
|
|
|
|
"Input is neither String nor Array");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = absolute;
|
|
|
|
|
2016-03-12 08:36:30 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5hYnNvbHV0ZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwwQ0FBMEM7QUFDMUMsSUFBTyxPQUFPLFdBQVcscUJBQXFCLENBQUMsQ0FBQztBQUVoRCxJQUFJLFlBQVksR0FBRyxVQUFTLFlBQW1CLEVBQUUsT0FBZTtJ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