From ed79a803b083f8572313062fd38690ff37b7aec9 Mon Sep 17 00:00:00 2001 From: tenorok Date: Mon, 20 Oct 2014 16:29:05 +0400 Subject: [PATCH 1/6] =?UTF-8?q?=D0=A3=D0=BA=D0=B0=D0=B7=D0=B0=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8F=20jsdoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d861a04..9452bb6 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "devDependencies": { "mocha": "~1.15.1", "chai": "~1.8.1", - "jsdoc": "~3.3.0" + "jsdoc": "3.3.0-alpha8" }, "main": "main.js", "bin": { From 0dff2af49c743df1cba5351f1e08bde95b070a47 Mon Sep 17 00:00:00 2001 From: tenorok Date: Mon, 20 Oct 2014 16:47:11 +0400 Subject: [PATCH 2/6] =?UTF-8?q?=D0=9E=D0=BF=D1=86=D0=B8=D1=8F=20istanbul?= =?UTF-8?q?=20=D1=81=D0=BF=D0=BE=D1=81=D0=BE=D0=B1=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=83=D1=87=D0=B0=D1=82=D1=8C=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B2=D1=85=D0=BE=D0=B4=20=D0=BC=D0=B0=D1=81=D1=81=D0=B8=D0=B2?= =?UTF-8?q?=20=D0=B8=D0=BC=D1=91=D0=BD=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB?= =?UTF-8?q?=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maker.js | 15 ++++++++------- test/maker/helper.js | 4 ++-- test/maker/make-istanbul.js | 8 ++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/maker.js b/maker.js index 63f3b83..38f9b42 100644 --- a/maker.js +++ b/maker.js @@ -77,7 +77,7 @@ function Maker(options) { * @type {{ * directory: String|String[], * module: String|boolean, - * istanbul: String|boolean, + * istanbul: String|String[]|boolean, * postfix: String, * verbose: Array, * clean: Object, @@ -883,15 +883,16 @@ Maker.prototype = { * @returns {Object} */ markIstanbul: function(modules) { - var moduleToCoverage = this.options.istanbul; - if(!moduleToCoverage) return modules; + var modulesToCoverage = this.options.istanbul; + if(!modulesToCoverage) return modules; + + if(typeof modulesToCoverage === 'string') { + modulesToCoverage = [modulesToCoverage]; + } for(var i = 0; i < modules.length; i++) { - if(modules[i].name !== moduleToCoverage) { + if(!~modulesToCoverage.indexOf(modules[i].name)) { modules[i].istanbul = false; - } else { - modules[i].istanbul = true; - break; } } diff --git a/test/maker/helper.js b/test/maker/helper.js index 1093acf..f24b79a 100644 --- a/test/maker/helper.js +++ b/test/maker/helper.js @@ -281,7 +281,7 @@ var closure = { ' ){\n' + ' return a + b + \'c\';\n' + ' }).call(global, a, b, c),\n' + - 'e = (function (d) { return d + \'e\'; }).call(global, d),\n' + + 'e = /* istanbul ignore next */(function (d) { return d + \'e\'; }).call(global, d),\n' + 'f = (function () { return \'f\'; }).call(global);\n' + '})(this);'; }, @@ -290,7 +290,7 @@ var closure = { return '(function(global, undefined) {\n' + 'var a = /* istanbul ignore next */(function () { return \'a\'; }).call(global),\n' + 'b = (function (a){return a + \'b\';}).call(global, a),\n' + - 'c = (function (a, b) {\n' + + 'c = /* istanbul ignore next */(function (a, b) {\n' + ' return a + b + \'c\';\n' + '}).call(global, a, b);\n' + '})(this);'; diff --git a/test/maker/make-istanbul.js b/test/maker/make-istanbul.js index 91ab1e9..30c04e4 100644 --- a/test/maker/make-istanbul.js +++ b/test/maker/make-istanbul.js @@ -12,11 +12,11 @@ describe('Сборка модулей для тестирования покры var savePromise = vow.promise(), saveFilePath = path.join(__dirname, 'modules/all.js'); - it('Все обычные модули', function(done) { + it('Все обычные модули и несколько целевых модулей для istanbul', function(done) { new Maker({ directory: path.join(__dirname, 'modules'), - istanbul: 'd', + istanbul: ['d', 'f'], verbose: ['error'] }).make(saveFilePath).then(function() { @@ -29,7 +29,7 @@ describe('Сборка модулей для тестирования покры }).done(); }); - it('Заданный модуль', function(done) { + it('Заданный модуль для сборки с одним целевым модулем для istanbul', function(done) { new Maker({ directory: path.join(__dirname, 'modules'), @@ -47,7 +47,7 @@ describe('Сборка модулей для тестирования покры }).done(); }); - it('Заданные модуль с присутствием экспортируемых модулей', function(done) { + it('Заданный модуль с присутствием экспортируемых модулей', function(done) { new Maker({ directory: path.join(__dirname, 'modules2'), From 2db1d020b0a429689fb4534235c71451052f5a42 Mon Sep 17 00:00:00 2001 From: tenorok Date: Mon, 20 Oct 2014 18:23:39 +0400 Subject: [PATCH 3/6] =?UTF-8?q?CLI=20=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=BD=D0=BE=20=D0=BF=D1=80=D0=B8=D0=BD=D0=B8=D0=BC=D0=B0?= =?UTF-8?q?=D0=B5=D1=82=20=D0=BD=D0=B5=D1=81=D0=BA=D0=BE=D0=BB=D1=8C=D0=BA?= =?UTF-8?q?=D0=BE=20=D0=B8=D0=BC=D1=91=D0=BD=20=D0=BC=D0=BE=D0=B4=D1=83?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9=20=D0=B2=20=D0=BE=D0=BF=D1=86=D0=B8=D0=B8=20?= =?UTF-8?q?istanbul?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cli.js | 8 +++++--- test/maker/make-istanbul.js | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cli.js b/cli.js index 6107111..1f1ad49 100644 --- a/cli.js +++ b/cli.js @@ -12,11 +12,13 @@ const path = require('path'), commander .version('0.0.4') .usage('[options] ') - .option('-d, --directory ', 'directory of modules, comma delimited', '.') + .option('-d, --directory ', 'directory of modules, comma delimited', '.') .option('-m, --module ', 'target module name') - .option('-i, --istanbul ', 'target module name to coverage by istanbul') + .option('-i, --istanbul ', 'names of modules to coverage by istanbul, comma delimited', + function(modules) { return modules.split(','); }) .option('-p, --postfix ', 'postfix to find files') - .option('-v, --verbose ', 'l - log, i - info, w - warn, e - error', function(modes) { return modes.split(''); }) + .option('-v, --verbose ', 'l - log, i - info, w - warn, e - error', + function(modes) { return modes.split(''); }) .option('-c, --config ', 'json format config', defaultConfigFile) .parse(process.argv); diff --git a/test/maker/make-istanbul.js b/test/maker/make-istanbul.js index 30c04e4..d731af7 100644 --- a/test/maker/make-istanbul.js +++ b/test/maker/make-istanbul.js @@ -77,8 +77,8 @@ describe('Сборка модулей для тестирования покры var cli = new helper.testCLI('./bin/definer -v e -d test/maker/modules/').setTarget('test/maker/modules/all.js'); - it('Все обычные модули', function(done) { - cli.exec('-i d', helper.getClosureStringIstanbul(), done); + it('Все обычные модули и несколько целевых модулей для istanbul', function(done) { + cli.exec('-i d,f', helper.getClosureStringIstanbul(), done); }); after(function(done) { From 16ea3109913660ecb9018b2db37be62248e79336 Mon Sep 17 00:00:00 2001 From: tenorok Date: Mon, 20 Oct 2014 19:21:08 +0400 Subject: [PATCH 4/6] =?UTF-8?q?Istanbul-=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D0=B0=D1=80=D0=B8=D0=B9=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D1=8F=D0=B5=D1=82=D1=81=D1=8F=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=B4=20clean-=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D0=B0?= =?UTF-8?q?=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maker.js | 11 ++++++++++- test/maker/helper.js | 16 +++++++++++++++- test/maker/make-istanbul.js | 9 +++++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/maker.js b/maker.js index 38f9b42..3e91707 100644 --- a/maker.js +++ b/maker.js @@ -109,6 +109,14 @@ function Maker(options) { */ Maker.cacheFiles = {}; +/** + * Комментарий для указания istanbul игнорировать блоки кода + * @private + * @constant + * @type {String} + */ +Maker.ISTANBUL_COMMENT = '/* istanbul ignore next */'; + Maker.prototype = { /** @@ -591,6 +599,7 @@ Maker.prototype = { if(!this.clean.length) return ''; this.clean.unshift( + (this.options.istanbul !== false ? Maker.ISTANBUL_COMMENT : '') + '(function(undefined) {', 'var exports = undefined, modules = undefined, define = undefined;' ); @@ -641,7 +650,7 @@ Maker.prototype = { var closure = [ module.name, ' = ', - module.istanbul === false ? '/* istanbul ignore next */' : '', + module.istanbul === false ? Maker.ISTANBUL_COMMENT : '', '(', module.body, ').call(global' diff --git a/test/maker/helper.js b/test/maker/helper.js index f24b79a..2d0d41a 100644 --- a/test/maker/helper.js +++ b/test/maker/helper.js @@ -304,7 +304,21 @@ var closure = { 'var z = /* istanbul ignore next */definer.export("z", (function () { return { nameZ: \'valueZ\' }; }).call(global)),\n' + 'y = (function (z) { return \'z\'; }).call(global, z);\n' + '})(this);'; - } + }, + + getClosureStringMakeCleanFilesModuleCIstanbul: function() { + return '/* istanbul ignore next */(function(undefined) {\n' + + 'var exports = undefined, modules = undefined, define = undefined;\n' + + '(function(global) { global.$ = \'jquery\'; })(this);\n' + + '(function(global) { (global.$ || {}).ui = \'jquery.ui\'; })(this);\n' + + '(function(global) { (global.$ || {}).plugin = \'jquery.plugin\'; })(this);\n' + + '}).call(this);\n' + + '(function(global, undefined) {\n' + + 'var $ = global.$,\n' + + 'c = (function ($) { return \'c\'; }).call(global, $);\n' + + '["$"].forEach(function(g) { delete global[g]; });\n' + + '})(this);'; + }, }; diff --git a/test/maker/make-istanbul.js b/test/maker/make-istanbul.js index d731af7..ec9901a 100644 --- a/test/maker/make-istanbul.js +++ b/test/maker/make-istanbul.js @@ -75,10 +75,15 @@ describe('Сборка модулей для тестирования покры describe('CLI.', function() { - var cli = new helper.testCLI('./bin/definer -v e -d test/maker/modules/').setTarget('test/maker/modules/all.js'); + var cli = new helper.testCLI('./bin/definer -v e').setTarget('test/maker/modules/all.js'); it('Все обычные модули и несколько целевых модулей для istanbul', function(done) { - cli.exec('-i d,f', helper.getClosureStringIstanbul(), done); + cli.exec('-d test/maker/modules/ -i d,f', helper.getClosureStringIstanbul(), done); + }); + + it('Clean-скрипты так же должны предваряться istanbul-комментарием', function(done) { + cli.exec('-d test/maker/clean/ -c test/maker/clean/clean.json -i c -m c', + helper.getClosureStringMakeCleanFilesModuleCIstanbul(), done); }); after(function(done) { From 2658ce626fc1d88a00d5a900152616aad4e25131 Mon Sep 17 00:00:00 2001 From: tenorok Date: Mon, 20 Oct 2014 19:26:19 +0400 Subject: [PATCH 5/6] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20readme=20=D0=B2=20=D1=81=D0=BE=D0=BE=D1=82=D0=B2?= =?UTF-8?q?=D0=B5=D1=82=D1=81=D1=82=D0=B2=D0=B8=D0=B8=20=D1=81=20=D0=B8?= =?UTF-8?q?=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=D0=BC=D0=B8=20?= =?UTF-8?q?=D0=BE=D0=BF=D1=86=D0=B8=D0=B8=20istanbul?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cc235d7..2c75d25 100644 --- a/README.md +++ b/README.md @@ -147,12 +147,15 @@ var a = (function () { return 'a'; }).call(global), ##### Опция `-i, --istanbul` -Опция позволяет указать имя модуля, для которого предполагается запуск [istanbul](https://github.com/gotwarlost/istanbul). -В результирующем файле у каждого модуля, который необходим для указанного модуля -будет добавлен комментарий, исключающий его из оценки покрытия тестами. +Опция позволяет перечислить имена модулей, для которых предполагается запуск [istanbul](https://github.com/gotwarlost/istanbul). +Для всех остальных модулей будет добавлен комментарий, исключающий их из оценки покрытия тестами. ./node_modules/.bin/definer -i b all.js +Возможно указание нескольких модулей через запятую. + + ./node_modules/.bin/definer -i b,c all.js + По умолчанию комментарии не добавляются, поскольку запуск оценки покрытия тестами не предполагается. ##### Опция `-v, --verbose` From 9829481eeda71ffb467593bbec70e6760b7232e6 Mon Sep 17 00:00:00 2001 From: tenorok Date: Mon, 20 Oct 2014 19:32:22 +0400 Subject: [PATCH 6/6] v0.2.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9452bb6..b4111b2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "definer", "description": "Easiest module system", - "version": "0.2.4", + "version": "0.2.5", "repository": { "type": "git", "url": "https://github.com/tenorok/definer.git"