now has better structure

This commit is contained in:
2016-03-20 18:59:30 +01:00
parent b113dcfbe0
commit 2bd242ac57
9 changed files with 145 additions and 47 deletions

View File

@ -1,14 +1,16 @@
/// <reference path="typings/main.d.ts" />
import plugins = require("./smartpath.plugins");
import SmartpathAbsolute = require("./smartpath.absolute");
import SmartpathTransform = require("./smartpath.transform");
import SmartpathGet = require("./smartpath.get");
/**
*
* @type {{getPath: (function(any): undefined)}}
*/
let smartpath = {
absolute: SmartpathAbsolute
transform: SmartpathTransform,
get: SmartpathGet
};

11
ts/smartpath.get.ts Normal file
View File

@ -0,0 +1,11 @@
/// <reference path="typings/main.d.ts" />
import plugins = require("./smartpath.plugins");
export let type = function(pathStringArg:string):string {
let urlRegex = /http[s|\s]:\/\/.*/i
if(urlRegex.exec(pathStringArg)){
return "url";
} else {
return "local";
};
};

View File

@ -1,7 +1,10 @@
/// <reference path="typings/main.d.ts" />
import plugins = require("./smartpath.plugins");
var makeAbsolute = function(localPathArg:string, baseArg?:string):string {
/* ------------------------------------------ *
* ------------ helpers --------------------- *
* ------------------------------------------ */
let makeAbsolute = function(localPathArg:string, baseArg?:string):string {
let absolutePath:string;
if(baseArg){
absolutePath = plugins.path.join(baseArg,localPathArg);
@ -11,7 +14,10 @@ var makeAbsolute = function(localPathArg:string, baseArg?:string):string {
return absolutePath;
};
var absolute = function(relativeArg:any, baseArg?:string):any {
/* ------------------------------------------ *
* ------- export functions ----------------- *
* ------------------------------------------ */
export let toAbsolute = function(relativeArg:any, baseArg?:string):any {
if(typeof relativeArg === "string"){
return makeAbsolute(relativeArg,baseArg);
} else if(Array.isArray(relativeArg)){
@ -26,6 +32,4 @@ var absolute = function(relativeArg:any, baseArg?:string):any {
"Input is neither String nor Array");
return false;
}
};
export = absolute;
};