Reliable path handling for Node.js, consistent across platforms.
npm install @harpertoken/cross-platform-path-utils
import {
createPath,
safeReadFile,
} from "@harpertoken/cross-platform-path-utils";
const path = createPath("dir", "file.txt");
const data = await safeReadFile(path, ["/allowed"]);
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
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.
Enforces standards for commit messages.
cp scripts/commit-msg .git/hooks/commit-msg
chmod +x .git/hooks/commit-msg
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
Use scripts/rewrite_msg.sh
with git filter-branch --msg-filter './scripts/rewrite_msg.sh' HEAD
.
MIT