fix(core): update

This commit is contained in:
2024-04-12 14:59:49 +02:00
parent b51ccda39e
commit fad06e3c33
7 changed files with 1339 additions and 1202 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartpath',
version: '5.0.11',
version: '5.0.12',
description: 'offers smart ways to handle paths'
}

View File

@ -4,13 +4,21 @@ import * as plugins from './smartpath.plugins.js';
* ------------ helpers --------------------- *
* ------------------------------------------ */
// checks a file
/**
* takes a path and makes it absolute
* @param localPathArg
* @param baseArg
* @returns
*/
export const makeAbsolute = (localPathArg: string, baseArg?: string): string => {
let absolutePath: string;
let alreadyAbsolute = plugins.path.isAbsolute(localPathArg);
if (baseArg && !alreadyAbsolute) {
if (!alreadyAbsolute && baseArg && !baseArg.startsWith('.')) {
absolutePath = plugins.path.join(baseArg, localPathArg);
} else if (!alreadyAbsolute) {
if (baseArg) {
plugins.path.join(baseArg, localPathArg);
}
absolutePath = plugins.path.resolve(localPathArg);
} else {
absolutePath = localPathArg;
@ -18,9 +26,9 @@ export const makeAbsolute = (localPathArg: string, baseArg?: string): string =>
return absolutePath;
};
/* ------------------------------------------ *
* ------- export functions ----------------- *
* ------------------------------------------ */
/*
* like makeAbsolute, but takes different complex contructs like arrays and objects
*/
export const toAbsolute = (relativeArg: string | string[], baseArg?: string): string | string[] => {
if (typeof relativeArg === 'string') {
return makeAbsolute(relativeArg, baseArg);