1.0.0 • Published 1 year ago

@icokie/filepath v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

file-path

Micro library for working with relative and absolute paths related to file name

npm version package size minified

total downloads total downloads per year total downloads per week total downloads per month

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!