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,8 +1,8 @@
// import modules
import * as check from './smartpath.check';
import * as get from './smartpath.get';
import * as transform from './smartpath.transform';
import * as check from './smartpath.check.js';
import * as get from './smartpath.get.js';
import * as transform from './smartpath.transform.js';
export { check, get, transform };
export * from './smartpath.classes.smartpath';
export * from './smartpath.classes.smartpath.js';

View File

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

View File

@ -1,5 +1,5 @@
import * as plugins from './smartpath.plugins';
import * as getMod from './smartpath.get';
import * as plugins from './smartpath.plugins.js';
import * as getMod from './smartpath.get.js';
export class Smartpath {
originalPath: string;

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();
};

View File

@ -1,4 +1,5 @@
import * as os from 'os';
import * as path from 'path';
import * as url from 'url';
export { os, path };
export { os, path, url };

View File

@ -1,11 +1,11 @@
import plugins = require('./smartpath.plugins');
import * as plugins from './smartpath.plugins.js';
/* ------------------------------------------ *
* ------------ helpers --------------------- *
* ------------------------------------------ */
// checks a file
let makeAbsolute = function(localPathArg: string, baseArg?: string): string {
let makeAbsolute = function (localPathArg: string, baseArg?: string): string {
let absolutePath: string;
let alreadyAbsolute = plugins.path.isAbsolute(localPathArg);
if (baseArg && !alreadyAbsolute) {
@ -21,7 +21,7 @@ let makeAbsolute = function(localPathArg: string, baseArg?: string): string {
/* ------------------------------------------ *
* ------- export functions ----------------- *
* ------------------------------------------ */
export let toAbsolute = function(relativeArg: string | string[], baseArg?: string): any {
export let toAbsolute = function (relativeArg: string | string[], baseArg?: string): any {
if (typeof relativeArg === 'string') {
return makeAbsolute(relativeArg, baseArg);
} else if (Array.isArray(relativeArg)) {