TypeSafe Path
This library is aim to explicitly annotate path format of the code, and throwing error when passing incorrect format paths.
The advantage is that we can avoid using upath
to convert all paths to unix path, and ensure current code logic always correctly know the path format that should be processed.
Please note that you should only use it in your modules that are coupled to the filesystem.
Usage
import * as path from 'typesafe-path';
const osPath = __dirname as path.OsPath;
const win32Path = '..\\aaa\\bbb' as path.Win32Path;
path.resolve(osPath, win32Path);
const posixPath = win32Path.replace(/\\/g, '/') as path.PosixPath;
path.resolve(osPath, posixPath);