Package Exports
- cli-path-resolve
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cli-path-resolve) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
cli-path-resolve
resolve/normalize a filepath using the cwd as the basepath if relative
installation
$ npm install cli-path-resolveusage
If an argument is passed to your cli script that points to the file system, it can be absolute or relative.
If it's relative - this module will use the current working directory (process.cwd) as the basedir.
globalscript.js
var args = require('minimist').parse(process.argv, {
alias:{
f:'filepath'
}
})
var resolve = require('cli-path-resolve')
var filepath = resolve(args.filepath)
// filepath is now normalized and absolute
console.log(filepath)If we have installed globalscript.js globally - we can run it from anywhere.
$ cd /home/myfolder
$ globalscript.js --filepath imgs/balloons.jpg
/home/myfolder/imgs/balloons.jpgapi
var resolved = resolve(path)
Will return path if it is absolute or will resolve it against process.cwd if its relative.
license
MIT