BREAKING CHANGE(package): change scope

This commit is contained in:
2018-07-21 23:26:11 +02:00
parent 09d424e972
commit 53905df003
30 changed files with 1185 additions and 636 deletions

View File

@@ -1,36 +1,36 @@
import plugins = require('./smartpath.plugins')
export type TPathType = 'url' | 'local'
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): TPathType {
let urlRegex = /http[s|\s]:\/\/.*/i
if (urlRegex.exec(pathStringArg)) {
return 'url'
} else {
return 'local'
};
}
export let type = function(pathStringArg: string): TPathType {
let urlRegex = /http[s|\s]:\/\/.*/i;
if (urlRegex.exec(pathStringArg)) {
return 'url';
} else {
return 'local';
}
};
export let home = function (pathArgument?: string) {
if (pathArgument) {
return plugins.home.resolve(pathArgument)
} else {
return plugins.home()
}
}
export let home = function(pathArgument?: string) {
if (pathArgument) {
return pathArgument.replace('~', plugins.os.homedir());
} else {
return plugins.os.homedir();
}
};
export type TSystemArg = 'dynamic' | 'windows' | 'linux' | 'osx'
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
}
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()
}
return pathLevels(pathArg, systemArg).reverse();
};