Skip to content

Commit

Permalink
Breaking: Rename option followSymlinks to resolveSymlinks (closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
erikkemperman authored and phated committed Nov 30, 2017
1 parent 8dfe08b commit 20fc47c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Type: `Boolean`

Default: `false`

##### `options.followSymlinks`
##### `options.resolveSymlinks`

Whether or not to recursively resolve symlinks to their targets. Setting to `false` to preserve them as symlinks and make `file.symlink` equal the original symlink's target path.

Expand Down
2 changes: 1 addition & 1 deletion lib/src/read-contents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function readContents(opt) {
return readDir(file, opt, onRead);
}

// Process symbolic links included with `followSymlinks` option
// Process symbolic links included with `resolveSymlinks` option
if (file.stat && file.stat.isSymbolicLink()) {
return readSymbolicLink(file, opt, onRead);
}
Expand Down
8 changes: 7 additions & 1 deletion lib/src/wrap-with-vinyl-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ var through2 = require('through2');
var fs = require('graceful-fs');
var File = require('vinyl');

var koalas = require('koalas');
var valueOrFunction = require('value-or-function');
var boolean = valueOrFunction.boolean;

function wrapWithVinylFile(options) {

var resolveSymlinks = koalas(boolean(options.resolveSymlinks), true);

// A stat property is exposed on file objects as a (wanted) side effect
function resolveFile(globFile, enc, callback) {
fs.lstat(globFile.path, onStat);
Expand All @@ -17,7 +23,7 @@ function wrapWithVinylFile(options) {

globFile.stat = stat;

if (!stat.isSymbolicLink() || !options.followSymlinks) {
if (!stat.isSymbolicLink() || !resolveSymlinks) {
var vinylFile = new File(globFile);
if (globFile.originalSymlinkPath) {
// If we reach here, it means there is at least one
Expand Down
2 changes: 1 addition & 1 deletion test/dest.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ describe('.dest()', function() {
contents: null,
});

// `src()` adds this side-effect with `followSymlinks` option set to false
// `src()` adds this side-effect with `resolveSymlinks` option set to false
file.symlink = inputRelativeSymlinkPath;

function assert(files) {
Expand Down
12 changes: 6 additions & 6 deletions test/src-symlinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('.src() with symlinks', function() {
done();
});

it('follows symlinks correctly', function(done) {
it('resolves symlinks correctly', function(done) {
function assert(files) {
expect(files.length).toEqual(1);
// The path should be the symlink itself
Expand All @@ -57,7 +57,7 @@ describe('.src() with symlinks', function() {
], done);
});

it('follows directory symlinks correctly', function(done) {
it('resolves directory symlinks correctly', function(done) {
function assert(files) {
expect(files.length).toEqual(1);
// The path should be the symlink itself
Expand All @@ -75,7 +75,7 @@ describe('.src() with symlinks', function() {
], done);
});

it('preserves file symlinks with followSymlinks option set to false', function(done) {
it('preserves file symlinks with resolveSymlinks option set to false', function(done) {
var expectedRelativeSymlinkPath = fs.readlinkSync(symlinkPath);

function assert(files) {
Expand All @@ -85,12 +85,12 @@ describe('.src() with symlinks', function() {
}

pipe([
vfs.src(symlinkPath, { followSymlinks: false }),
vfs.src(symlinkPath, { resolveSymlinks: false }),
concat(assert),
], done);
});

it('preserves directory symlinks with followSymlinks option set to false', function(done) {
it('preserves directory symlinks with resolveSymlinks option set to false', function(done) {
var expectedRelativeSymlinkPath = fs.readlinkSync(symlinkDirpath);

function assert(files) {
Expand All @@ -100,7 +100,7 @@ describe('.src() with symlinks', function() {
}

pipe([
vfs.src(symlinkDirpath, { followSymlinks: false }),
vfs.src(symlinkDirpath, { resolveSymlinks: false }),
concat(assert),
], done);
});
Expand Down

0 comments on commit 20fc47c

Please sign in to comment.