1.0.0 • Published 10 years ago
realpaths v1.0.0
realpaths
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
npm install realpathsAPI
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
- realpaths-callback (Callback-style version)
License
Copyright (c) 2015 Shinnosuke Watanabe
Licensed under the MIT License.