@harpertoken/cross-platform-path-utils
v0.1.0
Published
TypeScript utilities for cross-platform path handling and secure file operations
Maintainers
Readme
cross-platform-path-utils
Reliable path handling for Node.js, consistent across platforms.
Install
npm install @harpertoken/cross-platform-path-utilsUsage
import {
createPath,
safeReadFile,
} from "@harpertoken/cross-platform-path-utils";
const path = createPath("dir", "file.txt");
const data = await safeReadFile(path, ["/allowed"]);API
createPath(...parts): string- Joins path segments safelysafeReadFile(path, allowedDirs): Promise<string>- Reads files within allowed directoriesisPathInDirectory(path, dir): boolean- Checks if path is within directoryresolveFromFile(fromFile, toPath): string- Resolves relative paths
Development
Clone, install dependencies with npm install, test with npm test, build with npm run build.
Use path utilities over string concatenation, normalize paths, validate inputs, handle line endings, and test cross-platform.
Conventional Commits
Enforces standards for commit messages.
Setup
cp scripts/commit-msg .git/hooks/commit-msg
chmod +x .git/hooks/commit-msgRules
Start with type (feat, fix, docs, style, refactor, test, chore, perf, ci, build, revert) followed by : and description. Lowercase, ≤60 characters.
Example: feat: add path utility
History Cleanup
Use scripts/rewrite_msg.sh with git filter-branch --msg-filter './scripts/rewrite_msg.sh' HEAD.
License
MIT
