added Smartpath class and path level array
This commit is contained in:
@@ -1,22 +1,36 @@
|
||||
import "typings-global";
|
||||
import plugins = require("./smartpath.plugins");
|
||||
import plugins = require('./smartpath.plugins')
|
||||
export type TPathType = 'url' | 'local'
|
||||
|
||||
/**
|
||||
* returns the type of the given path. Can be "url" or "local"
|
||||
*/
|
||||
export let type = function(pathStringArg:string):string {
|
||||
export let type = function (pathStringArg: string): TPathType {
|
||||
let urlRegex = /http[s|\s]:\/\/.*/i
|
||||
if(urlRegex.exec(pathStringArg)){
|
||||
return "url";
|
||||
if (urlRegex.exec(pathStringArg)) {
|
||||
return 'url'
|
||||
} else {
|
||||
return "local";
|
||||
return 'local'
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export let home = function(pathArgument?:string){
|
||||
if(pathArgument){
|
||||
return plugins.home.resolve(pathArgument);
|
||||
export let home = function (pathArgument?: string) {
|
||||
if (pathArgument) {
|
||||
return plugins.home.resolve(pathArgument)
|
||||
} else {
|
||||
return plugins.home();
|
||||
return plugins.home()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export type TSystemArg = 'dynamic' | 'windows' | 'linux' | 'osx'
|
||||
|
||||
export let pathLevels = (pathArg: string, systemArg: TSystemArg = 'dynamic') => {
|
||||
let pathLevelArray: string[]
|
||||
if (systemArg === 'dynamic') {
|
||||
pathLevelArray = pathArg.split(plugins.path.sep)
|
||||
}
|
||||
return pathLevelArray
|
||||
}
|
||||
|
||||
export let pathLevelsBackwards = (pathArg: string, systemArg?: TSystemArg) => {
|
||||
return pathLevels(pathArg, systemArg).reverse()
|
||||
}
|
||||
|
Reference in New Issue
Block a user