Skip to content

Commit 82b1c4c

Browse files
author
contra
authored
Merge pull request #82 from jrpomeroy/include-file-obj
Pass the original file to the rename plugin
2 parents 5a1f34b + 85346dc commit 82b1c4c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function gulpRename(obj, options) {
3333

3434
} else if (type === 'function') {
3535

36-
obj(parsedPath);
36+
obj(parsedPath, file);
3737
path = Path.join(parsedPath.dirname, parsedPath.basename + parsedPath.extname);
3838

3939
} else if (type === 'object' && obj !== undefined && obj !== null) {

test/path-parsing.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,27 @@ describe('gulp-rename path parsing', function () {
113113
helper(srcPattern, obj, null, done, { multiExt: true });
114114
});
115115
});
116+
117+
describe('original file context', function () {
118+
it('passed to plugin as second argument', function (done) {
119+
var srcPattern = 'test/fixtures/hello.min.txt';
120+
var obj = function (path, file) {
121+
file.should.be.instanceof(Object);
122+
file.should.be.ok();
123+
};
124+
helper(srcPattern, obj, null, done, { multiExt: true });
125+
});
126+
127+
it('has expected properties', function (done) {
128+
var srcPattern = 'test/fixtures/hello.min.txt';
129+
var obj = function (path, file) {
130+
file.path.should.equal(Path.resolve(srcPattern));
131+
file.base.should.equal(Path.dirname(Path.resolve(srcPattern)));
132+
file.basename.should.equal(Path.basename(srcPattern));
133+
file.relative.should.equal(Path.basename(srcPattern));
134+
file.extname.should.equal(Path.extname(srcPattern));
135+
};
136+
helper(srcPattern, obj, null, done, { multiExt: true });
137+
});
138+
});
116139
});

0 commit comments

Comments
 (0)