Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
fix line  306  id去重错误 [spmjs#103](spmjs#103)
  • Loading branch information
sunylt committed Dec 8, 2016
1 parent 8426714 commit 266eeb7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tasks/lib/script.js
Expand Up @@ -303,11 +303,26 @@ exports.init = function(grunt) {
deps = grunt.util._.chain(deps)
.flatten()
.filter(function(item) {return typeof item !== 'undefined'})
.uniq(function(item) {return item.path})
//.uniq(function(item) {return item.path})
.each(function(item) {
if (item.relative) item.id = relative(path, item.path);
})
.value();

// 上面.uniq去重是有问题的,依赖的 id 没有 path 并不能扔掉
var _deps = [],
_idsCache = {};

deps.forEach(function(item) {
if (!(item.id in _idsCache)) {
_deps.push(item);
_idsCache[item.id] = 1;
}
});

deps = _deps;
_idsCache = null;

grunt.log.verbose.writeln(deps.length ?
'found dependencies ' + deps : 'found no dependencies');
}
Expand Down

0 comments on commit 266eeb7

Please sign in to comment.