0.1.0 • Published 9 years ago
file-symlinks v0.1.0
file-symlinks
Resolve symlinks and expose the
stat
property on a file object.
This is inspired by the file.stat
code in vinyl-fs. I needed a function that essentially did the same thing but could be used with stream or non-stream code.
Install
Install with npm
$ npm i file-symlinks --save
Usage
var symlinks = require('file-symlinks');
var through = require('through2');
function toStream(fp) {
var stream = through.obj();
stream.write({path: fp});
stream.end();
return stream;
}
toStream('fake.md')
.pipe(symlinks())
.on('data', function (file) {
// path.basename(file.path) => 'README.md'
})
async
The symlinks.resolve()
method is exposed for non-stream usage.
// assuming you have a symlink, `fake.md` which points to `README.md`
symlinks.resolve({path: 'fake.md'}, function (err, file) {
// file.path => 'README.md'
});
// with `realpath: false`
symlinks.resolve({path: 'fake.md'}, {realpath: false}, function (err, file) {
// file.path => 'fake.md'
});
Related projects
- file-contents: Set the
contents
property on a file object in a stream. - file-stat: Set the
stat
property on a file object in a stream. - stream-loader: create a read stream from a glob of files. can be used as a loader-cache… more
- vinyl: A virtual file format
- vinyl-fs: Vinyl adapter for the file system
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on July 15, 2015.
0.1.0
9 years ago