fix(core): update

This commit is contained in:
2022-03-14 13:26:48 +01:00
parent 618b3da86e
commit ddfae30a18
15 changed files with 17592 additions and 754 deletions

View File

@@ -1,11 +1,11 @@
import plugins = require('./smartpath.plugins');
import * as plugins from './smartpath.plugins.js'
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;
export const type = (pathStringArg: string): TPathType => {
const urlRegex = /http[s|\s]:\/\/.*/i;
if (urlRegex.exec(pathStringArg)) {
return 'url';
} else {
@@ -13,7 +13,19 @@ export let type = function(pathStringArg: string): TPathType {
}
};
export let home = function(pathArgument?: string) {
/**
* gets the dirname from import.meta.url
*/
export const getDirnameFromImportMetaUrl = () => {
}
/**
* returns homedir as absolute path
* @param pathArgument if a pathargument is given, ~ is being replaced with the homedir
* @returns
*/
export const home = (pathArgument?: string) => {
if (pathArgument) {
return pathArgument.replace('~', plugins.os.homedir());
} else {
@@ -23,7 +35,7 @@ export let home = function(pathArgument?: string) {
export type TSystemArg = 'dynamic' | 'windows' | 'linux' | 'osx';
export let pathLevels = (pathArg: string, systemArg: TSystemArg = 'dynamic') => {
export const pathLevels = (pathArg: string, systemArg: TSystemArg = 'dynamic') => {
let pathLevelArray: string[];
if (systemArg === 'dynamic') {
pathLevelArray = pathArg.split(plugins.path.sep);
@@ -31,6 +43,6 @@ export let pathLevels = (pathArg: string, systemArg: TSystemArg = 'dynamic') =>
return pathLevelArray;
};
export let pathLevelsBackwards = (pathArg: string, systemArg?: TSystemArg) => {
export const pathLevelsBackwards = (pathArg: string, systemArg?: TSystemArg) => {
return pathLevels(pathArg, systemArg).reverse();
};