Skip to content

Commit

Permalink
Fix: Proxy cwd if base is set to same value (fixes #129)
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Apr 18, 2017
1 parent 12d62da commit 07e4093
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ Object.defineProperty(File.prototype, 'base', {
base = removeTrailingSep(normalize(base));
if (base !== this._cwd) {
this._base = base;
} else {
delete this._base;
}
},
});
Expand Down
11 changes: 11 additions & 0 deletions test/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,17 @@ describe('File', function() {
done();
});

it('proxies to cwd when set to same value', function(done) {
var file = new File({
cwd: '/foo',
base: '/bar',
});
expect(file.base).toNotEqual(file.cwd);
file.base = file.cwd;
expect(file.base).toEqual(file.cwd);
done();
});

it('proxies to cwd when null or undefined', function(done) {
var file = new File({
cwd: '/foo',
Expand Down

0 comments on commit 07e4093

Please sign in to comment.