1.0.0 • Published 8 years ago

realpaths v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

realpaths

NPM version Build Status Coverage Status Dependency Status devDependency Status

Like fs.realpath, but resolves multiple paths at once

const realpaths = require('realpaths');

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

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

Installation

Use npm.

npm install realpaths

API

const realpaths = require('realpaths');

realpaths(paths , cache)

paths: Array of strings (file paths)
options: Object (used as fs.realpath cache)
Return: Promise instance

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.

When it fails to resolve at least one of the paths, it will be rejected.

'use strict';

const path = require('path');
const realpaths = require('realpaths-callback');

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

Related projects

License

Copyright (c) 2015 Shinnosuke Watanabe

Licensed under the MIT License.