fix(core): update
This commit is contained in:
@ -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'
|
||||
}
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user