1.0.0 • Published 1 year ago
@icokie/filepath v1.0.0
file-path
Micro library for working with relative and absolute paths related to file name
Usage:
Useful when you need to know relative path to file by its name
import { getRelativeFileName, getRelativePathToFile } from '@icokie/filepath';
const relativePathWithFileNameToPackageJsonFromCWD = getRelativeFileName('package.json');
// if CWD is project root then will return just file name 'pakcage.json'
// if CWD is project src then will return '../pakcage.json'
const relativePathToPackageJsonFromCWD = getRelativePathToFile('package.json');
// if CWD is project root then will return just file name '.'
// if CWD is project src then will return '..'
That's it!
1.0.0
1 year ago