path-here

2018-09-15 admin

path-here是什么

什么是path-here,A simple module to get the path with __dirname

path-here使用教程帮助文档

path-here

Status: npm version npm downloads Build Status Code Coverage

This micro-lib will take your code from this:

var path = require('path');
var srcDirectory = path.resolve('src');

to this:

var here = require('path-here');
var srcDirectory = here('src');

Note: This is actually not all that useful. Originally when I made this I thought it was doing something it wasn’t. However, something more useful that it allows you to do (and the reason I haven’t deprecated it) is this:

var here = require('path-here');
var there = here.dir('~/Developer/starwars-names');
var starWarsNamesSrc = there('src');

Examples

var here = require('path-here');
var srcDir = here('src');
var somePath = here('some/path');
var somePathWithMultipleParams = here('some', 'path'); // <-- same result as previous
var withTrailingSlash = here('src/'); // <-- result has a trailing slash
var withPrefixSlash = here('/src'); // <-- same as here('src');

// specify a different root other than process.cwd()
var there = here.dir('/usr');
var bin = there('bin');

Other info

LICENSE -> MIT

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-40317.html

文章标题:path-here

回到顶部