Skip to content

Commit

Permalink
feat(rename): pass file to rename as a first arguments when it's a fu…
Browse files Browse the repository at this point in the history
…nction

This is a break change when using rename
  • Loading branch information
popomore committed May 5, 2015
1 parent 48fe2d0 commit 977000a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
6 changes: 1 addition & 5 deletions lib/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function getStream(opt) {
'.css': css(opt),
'.css.js': pipe(
// overide rename for this
css(extend({}, opt, {rename: rename, cssjs:true})),
css(extend({}, opt, {rename: {}, cssjs:true})),
css2js(opt)
),
'.json': json(opt),
Expand All @@ -120,10 +120,6 @@ function getStream(opt) {
});

return ret;

function rename(file) {
return file;
}
}

function chooseParseType(jsStream, cssStream) {
Expand Down
4 changes: 2 additions & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ function throwError() {

function getRenameOpts(file, opts) {
if (typeof opts === 'function') {
return opts;
return opts.bind(null, file);
}

opts = opts || {};
var ret = {suffix: ''};
if (opts.hash) {
Expand Down
5 changes: 4 additions & 1 deletion test/transport.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,10 @@ describe('Transport', function() {
var opt = {
cwd: cwd,
moduleDir: 'sea-modules',
rename: {hash:true}
rename: function(file, fileObj) {
fileObj.suffix = '-' + file.hash;
return fileObj;
}
};

vfs.src('index.js', {cwd: cwd, cwdbase: true})
Expand Down

0 comments on commit 977000a

Please sign in to comment.