From 30d4618a3fe7c2c5628b6a5e82fd48306649356a Mon Sep 17 00:00:00 2001 From: gemss Date: Wed, 15 Jan 2014 18:31:11 +0800 Subject: [PATCH] refact --- Gruntfile.js | 2 +- lib/common/filemap.js | 6 ++++-- lib/tasks/opti-jsp.js | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 47604fd..42a1129 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -73,7 +73,7 @@ module.exports = function(grunt) { // Src matches are relative to this path. cwd: '<%= pkg.config.src_js %>', // match all match files in the ${cwd}/ subdirectory and all of its subdirectories. - src: ['tinymce/**'], + src: ['api/ablesky.api.login.js', 'tinymce/**'], // Destination path prefix. dest: '<%= pkg.config.dest_js %>', filter: 'isFile' diff --git a/lib/common/filemap.js b/lib/common/filemap.js index 8cf7d16..c54289d 100755 --- a/lib/common/filemap.js +++ b/lib/common/filemap.js @@ -74,7 +74,6 @@ function sortDepends(deps, index) { deps[i] = deps[interchangeIndex]; deps[interchangeIndex] = tmp; - sortDepends(deps, index); break; } @@ -145,7 +144,10 @@ exports.addAmdDepends = function(identifier, deps) { deps = deps.map(function(element) { return (/\.js$/).test(element) ? element : element + '.js'; }); - exports.get(identifier).dependencies = exports.get(identifier).dependencies.concat(deps); + exports.get(identifier).dependencies = exports.get(identifier).dependencies.concat(deps).filter(function (ele, index, array) { + // rm duplicated element in this array. + return array.indexOf(ele) === index; + }); } return exports.get(identifier); diff --git a/lib/tasks/opti-jsp.js b/lib/tasks/opti-jsp.js index a996991..e3b68b1 100755 --- a/lib/tasks/opti-jsp.js +++ b/lib/tasks/opti-jsp.js @@ -138,6 +138,8 @@ module.exports = function(grunt) { log.debug(2); // jsp file is head-content.jsp || includeJS.jsp sourceContent += filemapTmpl(gexcludes); + // add global deps, add them to filemap. + filemap.addAmdDepends(sourceIdentifier, gexcludes); } else { if (headCloseTagExpr.test(sourceContent)) { log.debug(3);