Skip to content

shinnn/realpaths

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

realpaths

npm version Build Status Coverage Status

Like fs.realpath, but resolves multiple paths at once

const realpaths = require('realpaths');

// symlink1 <<===>> /path/to/foo.txt
// symlink2 <<===>> /path/to/bar.txt

(async () => {
  await realpaths(['symlink1', 'symlink2']) //=> ['/path/to/foo.txt', '/path/to/bar.txt']
})();

Installation

Use npm.

npm install realpaths

API

const realpaths = require('realpaths');

realpaths(paths [, cache])

paths: Array<string> (file paths)
options: Object (used as fs.realpath cache)
Return: Promise<Array<string>>

It runs fs.realpath for each path and returns a Promise instance.

When it finishes resolving all paths, it will be fulfilled with an array of resolved paths.

const {resolve} = require('path');
const realpaths = require('realpaths-callback');

realpaths(['symlink1', 'symlink2'], {
  cache: {
    [resolve('symlink1')]: '/path/to/foo.txt',
    [resolve('symlink2')]: '/path/to/bar.txt'
  }
}).then(paths => {
  paths; //=> ['/path/to/foo.txt', '/path/to/bar.txt']
});

Related projects

License

ISC License © 2017 Shinnosuke Watanabe

About

Like fs.realpath, but resolves multiple paths at once

Resources

License

Stars

Watchers

Forks

Packages

No packages published