Skip to content

Commit 7cb3edc

Browse files
committed
Merge pull request #24 from adam-lynch/patch-1
Don't check what's returned from passed function
2 parents bea28cd + c9a82f6 commit 7cb3edc

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ function gulpRename(obj) {
2828

2929
} else if (type === "function") {
3030

31-
var result = obj(parsedPath) || parsedPath;
32-
path = Path.join(result.dirname, result.basename + result.extname);
31+
obj(parsedPath);
32+
path = Path.join(parsedPath.dirname, parsedPath.basename + parsedPath.extname);
3333

3434
} else if (type === "object" && obj !== undefined && obj !== null) {
3535

test/rename.spec.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,24 @@ describe("gulp-rename", function () {
150150
helper(srcPattern, obj, expectedPath, done);
151151
});
152152

153-
it("can return a whole new object", function (done) {
153+
it("ignores the return value", function (done) {
154154
var obj = function (/*path*/) {
155155
return {
156156
dirname: "elsewhere",
157157
basename: "aloha",
158158
extname: ".md"
159159
};
160160
};
161-
var expectedPath = "test/elsewhere/aloha.md";
161+
var expectedPath = "test/fixtures/hello.txt";
162+
helper(srcPattern, obj, expectedPath, done);
163+
});
164+
165+
it("receives object with extname even if a different value is returned", function (done) {
166+
var obj = function (path) {
167+
path.extname.should.equal(".txt");
168+
return path.extname = ".md";
169+
};
170+
var expectedPath = "test/fixtures/hello.md";
162171
helper(srcPattern, obj, expectedPath, done);
163172
});
164173
});

0 commit comments

Comments
 (0)