improve absolute path handling

This commit is contained in:
Philipp Kunz 2016-09-30 17:08:09 +02:00
parent e09ce0edc0
commit 3d0257768d
17 changed files with 106 additions and 103 deletions

10
.gitignore vendored
View File

@ -1,8 +1,4 @@
node_modules/
.settings/
.idea/
docs/
ts/typings/
ts/**/*.js
ts/**/*.js.map
coverage/
coverage/
pages/
public/

8
dist/index.d.ts vendored
View File

@ -1,7 +1,7 @@
import "typings-global";
import SmartpathCheck = require("./smartpath.check");
import SmartpathGet = require("./smartpath.get");
import SmartpathTransform = require("./smartpath.transform");
import 'typings-global';
import SmartpathCheck = require('./smartpath.check');
import SmartpathGet = require('./smartpath.get');
import SmartpathTransform = require('./smartpath.transform');
/**
*
* @type {{getPath: (function(any): undefined)}}

12
dist/index.js vendored
View File

@ -1,17 +1,17 @@
"use strict";
require("typings-global");
var SmartpathCheck = require("./smartpath.check");
var SmartpathGet = require("./smartpath.get");
var SmartpathTransform = require("./smartpath.transform");
// import modules
const SmartpathCheck = require("./smartpath.check");
const SmartpathGet = require("./smartpath.get");
const SmartpathTransform = require("./smartpath.transform");
/**
*
* @type {{getPath: (function(any): undefined)}}
*/
var smartpath = {
let smartpath = {
check: SmartpathCheck,
get: SmartpathGet,
transform: SmartpathTransform
};
module.exports = smartpath;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFFeEIsSUFBTyxjQUFjLFdBQVcsbUJBQW1CLENBQUMsQ0FBQztBQUNyRCxJQUFPLFlBQVksV0FBVyxpQkFBaUIsQ0FBQyxDQUFDO0FBQ2pELElBQU8sa0JBQWtCLFdBQVcsdUJBQXVCLENBQUMsQ0FBQztBQUU3RDs7O0dBR0c7QUFDSCxJQUFJLFNBQVMsR0FBRztJQUNaLEtBQUssRUFBRSxjQUFjO0lBQ3JCLEdBQUcsR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Q3JCLEdBQUcsRUFBRSxZQUFZO0lBQ2pCLFNBQVMsRUFBRSxrQkFBa0I7Q0FDaEMsQ0FBQTtBQUVELGlCQUFTLFNBQVMsQ0FBQSJ9

View File

@ -1,3 +1,3 @@
import "typings-global";
import 'typings-global';
export declare let isDir: (pathArg: string) => boolean;
export declare let isFile: (pathArg: any) => boolean;

View File

@ -6,5 +6,4 @@ exports.isDir = function (pathArg) {
exports.isFile = function (pathArg) {
return /\.[a-zA-Z]*$/.test(pathArg); // checks if there is a .anything at the end
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5jaGVjay50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBR2IsYUFBSyxHQUFHLFVBQVMsT0FBYztJQUN0QyxNQUFNLENBQUMsQ0FBQyxjQUFNLENBQUMsT0FBTyxDQUFDLENBQUM7QUFDNUIsQ0FBQyxDQUFBO0FBRVUsY0FBTSxHQUFHLFVBQVMsT0FBTztJQUNoQyxNQUFNLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDLDRDQUE0QztBQUNyRixDQUFDLENBQUEiLCJmaWxlIjoic21hcnRwYXRoLmNoZWNrLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vc21hcnRwYXRoLnBsdWdpbnNcIik7XG5cbmV4cG9ydCBsZXQgaXNEaXIgPSBmdW5jdGlvbihwYXRoQXJnOnN0cmluZyl7XG4gICAgcmV0dXJuICFpc0ZpbGUocGF0aEFyZyk7XG59XG5cbmV4cG9ydCBsZXQgaXNGaWxlID0gZnVuY3Rpb24ocGF0aEFyZyl7XG4gICAgcmV0dXJuIC9cXC5bYS16QS1aXSokLy50ZXN0KHBhdGhBcmcpOyAvLyBjaGVja3MgaWYgdGhlcmUgaXMgYSAuYW55dGhpbmcgYXQgdGhlIGVuZFxufSJdfQ==
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRwYXRoLmNoZWNrLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRwYXRoLmNoZWNrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFHWixRQUFBLEtBQUssR0FBRyxVQUFTLE9BQWU7SUFDdkMsTUFBTSxDQUFDLENBQUMsY0FBTSxDQUFDLE9BQU8sQ0FBQyxDQUFBO0FBQzNCLENBQUMsQ0FBQTtBQUVVLFFBQUEsTUFBTSxHQUFHLFVBQVMsT0FBTztJQUNoQyxNQUFNLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsQ0FBQSxDQUFDLDRDQUE0QztBQUNwRixDQUFDLENBQUEifQ==

View File

@ -1,11 +1,11 @@
"use strict";
require("typings-global");
var plugins = require("./smartpath.plugins");
const plugins = require("./smartpath.plugins");
/**
* returns the type of the given path. Can be "url" or "local"
*/
exports.type = function (pathStringArg) {
var urlRegex = /http[s|\s]:\/\/.*/i;
let urlRegex = /http[s|\s]:\/\/.*/i;
if (urlRegex.exec(pathStringArg)) {
return "url";
}
@ -22,5 +22,4 @@ exports.home = function (pathArgument) {
return plugins.home();
}
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5nZXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUN4QixJQUFPLE9BQU8sV0FBVyxxQkFBcUIsQ0FBQyxDQUFDO0FBRWhEOztHQUVHO0FBQ1EsWUFBSSxHQUFHLFVBQVMs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ZLENBQUMsQ0FBQztJQUM5QyxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixNQUFNLENBQUMsT0FBTyxDQUFDLElBQUksRUFBRSxDQUFDO0lBQzFCLENBQUM7QUFDTCxDQUFDLENBQUMifQ==

View File

@ -1,4 +1,4 @@
import "typings-global";
export import beautylog = require("beautylog");
import 'typings-global';
export import beautylog = require('beautylog');
export declare var home: any;
export import path = require("path");
export import path = require('path');

View File

@ -1,7 +1,6 @@
"use strict";
require("typings-global");
exports.beautylog = require("beautylog");
exports.home = require("home");
exports.home = require('home');
exports.path = require("path");
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixpQkFBUyxXQUFZLFdBQVcsQ0FBQyxDQUFDO0FBQ3JDLFlBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUM7QUFDcEIsWUFBSSxXQUFXLE1BQU0sQ0FBQyxDQUFDIiwiZmlsZSI6InNtYXJ0cGF0aC5wbHVnaW5zLmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IFwidHlwaW5ncy1nbG9iYWxcIjtcbmV4cG9ydCBpbXBvcnQgYmVhdXR5bG9nID0gcmVxdWlyZSAoXCJiZWF1dHlsb2dcIik7XG5leHBvcnQgdmFyIGhvbWUgPSByZXF1aXJlKFwiaG9tZVwiKTtcbmV4cG9ydCBpbXBvcnQgcGF0aCA9IHJlcXVpcmUoXCJwYXRoXCIpO1xuXG4iXX0=
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRwYXRoLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHBhdGgucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXVCO0FBQ3ZCLHlDQUErQztBQUNwQyxRQUFBLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUE7QUFDakMsK0JBQW9DIn0=

View File

@ -1,2 +1,2 @@
import "typings-global";
export declare let toAbsolute: (relativeArg: any, baseArg?: string) => any;
import 'typings-global';
export declare let toAbsolute: (relativeArg: string | string[], baseArg?: string) => any;

View File

@ -1,40 +1,43 @@
"use strict";
require("typings-global");
var plugins = require("./smartpath.plugins");
const plugins = require("./smartpath.plugins");
/* ------------------------------------------ *
* ------------ helpers --------------------- *
* ------------------------------------------ */
var makeAbsolute = function (localPathArg, baseArg) {
var absolutePath;
if (baseArg) {
// checks a file
let makeAbsolute = function (localPathArg, baseArg) {
let absolutePath;
let alreadyAbsolute = plugins.path.isAbsolute(localPathArg);
if (baseArg && !alreadyAbsolute) {
absolutePath = plugins.path.join(baseArg, localPathArg);
}
else {
else if (!alreadyAbsolute) {
absolutePath = plugins.path.resolve(localPathArg);
}
else {
absolutePath = localPathArg;
}
return absolutePath;
};
/* ------------------------------------------ *
* ------- export functions ----------------- *
* ------------------------------------------ */
exports.toAbsolute = function (relativeArg, baseArg) {
if (typeof relativeArg === "string") {
if (typeof relativeArg === 'string') {
return makeAbsolute(relativeArg, baseArg);
}
else if (Array.isArray(relativeArg)) {
var relativeArray = relativeArg;
var absoluteArray = [];
for (var key in relativeArray) {
let relativeArray = relativeArg;
let absoluteArray = [];
for (let key in relativeArray) {
absoluteArray.push(makeAbsolute(relativeArray[key], baseArg));
}
;
return absoluteArray;
}
else {
plugins.beautylog.error("smartpath.absolute() could not make sense of the input. " +
"Input is neither String nor Array");
plugins.beautylog.error('smartpath.absolute() could not make sense of the input. ' +
'Input is neither String nor Array');
return false;
}
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0cGF0aC50cm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LFVBQVUsR0FBRyxVQUFTLFdBQThCLEVBQUUsT0FBZ0I7SUFDN0UsRUFBRSxDQUFDLENBQUMsT0FBTyxXQUFXLEtBQUssUUFBUSxDQUFDLENBQUMsQ0FBQztRQUNsQyxNQUFNLENBQUMsWUFBWSxDQUFDLFdBQVcsRUFBQyxPQUFPLENBQUMsQ0FBQTtJQUM1QyxDQUFDO0lBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLEtBQUssQ0FBQyxPQUFPLENBQUMsV0FBVyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQ3BDLElBQUksYUFBYSxHQUFHLFdBQVcsQ0FBQTtRQUMvQixJQUFJLGFBQWEsR0FBYSxFQUFFLENBQUE7UUFDaEMsR0FBRyxDQUFDLENBQUMsSUFBSSxHQUFHLElBQUksYUFBYSxDQUFDLENBQUMsQ0FBQztZQUM1QixhQUFhLENBQUMsSUFBSSxDQUFDLFlBQVksQ0FBQyxhQUFhLENBQUMsR0FBRyxDQUFDLEVBQUMsT0FBTyxDQUFDLENBQUMsQ0FBQTtRQUNoRSxDQUFDO1FBQ0QsTUFBTSxDQUFDLGFBQWEsQ0FBQTtJQUN4QixDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQywwREFBMEQ7WUFDOUUsbUNBQW1DLENBQUMsQ0FBQTtRQUN4QyxNQUFNLENBQUMsS0FBSyxDQUFBO0lBQ2hCLENBQUM7QUFDTCxDQUFDLENBQUEifQ==

View File

@ -23,13 +23,13 @@
},
"homepage": "https://github.com/pushrocks/smartpath",
"dependencies": {
"beautylog": "^5.0.10",
"beautylog": "^5.0.23",
"home": "^1.0.1",
"typings-global": "^1.0.3"
"typings-global": "^1.0.14"
},
"devDependencies": {
"npmts-g": "^5.2.6",
"should": "^9.0.2",
"typings-test": "^1.0.1"
"npmts-g": "^5.2.8",
"should": "^11.1.0",
"typings-test": "^1.0.3"
}
}

File diff suppressed because one or more lines are too long

View File

@ -1,8 +1,10 @@
import "typings-global";
import plugins = require("./smartpath.plugins");
import SmartpathCheck = require("./smartpath.check");
import SmartpathGet = require("./smartpath.get");
import SmartpathTransform = require("./smartpath.transform");
import 'typings-global'
import plugins = require('./smartpath.plugins')
// import modules
import SmartpathCheck = require('./smartpath.check')
import SmartpathGet = require('./smartpath.get')
import SmartpathTransform = require('./smartpath.transform')
/**
*
@ -12,7 +14,6 @@ let smartpath = {
check: SmartpathCheck,
get: SmartpathGet,
transform: SmartpathTransform
};
}
export = smartpath;
export = smartpath

View File

@ -1,10 +1,10 @@
import "typings-global";
import plugins = require("./smartpath.plugins");
import 'typings-global'
import plugins = require('./smartpath.plugins')
export let isDir = function(pathArg:string){
return !isFile(pathArg);
export let isDir = function(pathArg: string){
return !isFile(pathArg)
}
export let isFile = function(pathArg){
return /\.[a-zA-Z]*$/.test(pathArg); // checks if there is a .anything at the end
}
return /\.[a-zA-Z]*$/.test(pathArg) // checks if there is a .anything at the end
}

View File

@ -1,5 +1,4 @@
import "typings-global";
export import beautylog = require ("beautylog");
export var home = require("home");
export import path = require("path");
import 'typings-global'
export import beautylog = require ('beautylog')
export var home = require('home')
export import path = require('path')

View File

@ -1,35 +1,40 @@
import "typings-global";
import plugins = require("./smartpath.plugins");
import 'typings-global'
import plugins = require('./smartpath.plugins')
/* ------------------------------------------ *
* ------------ helpers --------------------- *
* ------------------------------------------ */
let makeAbsolute = function(localPathArg:string, baseArg?:string):string {
let absolutePath:string;
if(baseArg){
absolutePath = plugins.path.join(baseArg,localPathArg);
// checks a file
let makeAbsolute = function(localPathArg: string, baseArg?: string): string {
let absolutePath: string
let alreadyAbsolute = plugins.path.isAbsolute(localPathArg)
if (baseArg && !alreadyAbsolute) {
absolutePath = plugins.path.join(baseArg,localPathArg)
} else if (!alreadyAbsolute) {
absolutePath = plugins.path.resolve(localPathArg)
} else {
absolutePath = plugins.path.resolve(localPathArg);
absolutePath = localPathArg
}
return absolutePath;
};
return absolutePath
}
/* ------------------------------------------ *
* ------- export functions ----------------- *
* ------------------------------------------ */
export let toAbsolute = function(relativeArg:any, baseArg?:string):any {
if(typeof relativeArg === "string"){
return makeAbsolute(relativeArg,baseArg);
} else if(Array.isArray(relativeArg)){
export let toAbsolute = function(relativeArg: string | string[], baseArg?: string): any {
if (typeof relativeArg === 'string') {
return makeAbsolute(relativeArg,baseArg)
} else if (Array.isArray(relativeArg)) {
let relativeArray = relativeArg
let absoluteArray:string[] = [];
for (let key in relativeArray){
absoluteArray.push(makeAbsolute(relativeArray[key],baseArg));
};
return absoluteArray;
let absoluteArray: string[] = []
for (let key in relativeArray) {
absoluteArray.push(makeAbsolute(relativeArray[key],baseArg))
}
return absoluteArray
} else {
plugins.beautylog.error("smartpath.absolute() could not make sense of the input. " +
"Input is neither String nor Array");
return false;
plugins.beautylog.error('smartpath.absolute() could not make sense of the input. ' +
'Input is neither String nor Array')
return false
}
};
}

3
tslint.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "tslint-config-standard"
}