file-lookup

0.0.2 • Public • Published

node-file-lookup

指定一组目录,依次搜索指定文件(相对路径),返回其绝对文件路径,支持同步和异步方法

使用方法:

var FileLookup = require('file-lookup');
 
var lookup = new FileLookup();
 
// 添加一系列目录,按添加顺序搜索
loolup.add('/path/1');
loolup.add('/path/2');
 
// 取实际文件名
lookup.resolve('file', function (filename) {
  if (filename) {
    console.log('Path: %s', filename);
  } else {
    console.log('Cannot lookup file');
  }
});
 
// 同步版本
var filename = lookup.resolveSync('file');
if (filename) {
  console.log('Path: %s', filename);
} else {
  console.log('Cannot lookup file');
}

Readme

Keywords

Package Sidebar

Install

npm i file-lookup

Weekly Downloads

3

Version

0.0.2

License

MIT

Last publish

Collaborators

  • leizongmin