@dreamhorizonorg/sentinel
Version:
Open-source, zero-dependency tool that blocks compromised packages BEFORE download. Built to counter supply chain and credential theft attacks like Shai-Hulud.
47 lines (38 loc) • 971 B
JavaScript
/**
* Path resolution utilities
* Pure functions for path manipulation and resolution
*/
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
/**
* Get the project root directory
*/
export const getProjectRoot = () => {
return path.join(__dirname, '..', '..');
};
/**
* Get user home directory path
*/
export const getUserHome = () => {
return process.env.HOME ?? process.env.USERPROFILE ?? '';
};
/**
* Resolve path relative to project root
*/
export const resolveProjectPath = (...segments) => {
return path.join(getProjectRoot(), ...segments);
};
/**
* Resolve path relative to user home
*/
export const resolveUserPath = (...segments) => {
return path.join(getUserHome(), ...segments);
};
/**
* Resolve absolute path from relative path
*/
export const resolveAbsolutePath = (relativePath) => {
return path.resolve(relativePath);
};