Skip to content

Commit

Permalink
[npm publish] - npm publish 2017.11.21
Browse files Browse the repository at this point in the history
- update build
  • Loading branch information
kaizhu256 committed Nov 22, 2017
1 parent ef1be4d commit 50e5c75
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 49 deletions.
83 changes: 61 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# istanbul-lite
this zero-dependency package will provide a browser-compatible version of the istanbul (v0.4.5) coverage-tool
this zero-dependency package will provide a browser-compatible version of the istanbul (v0.4.5) coverage-tool, with a working web-demo

# live demo
# live web demo
- [https://kaizhu256.github.io/node-istanbul-lite/build..beta..travis-ci.org/app](https://kaizhu256.github.io/node-istanbul-lite/build..beta..travis-ci.org/app)

[![screenshot](https://kaizhu256.github.io/node-istanbul-lite/build/screenshot.deployGithub.browser.%252Fnode-istanbul-lite%252Fbuild%252Fapp.png)](https://kaizhu256.github.io/node-istanbul-lite/build..beta..travis-ci.org/app)
Expand Down Expand Up @@ -58,9 +58,9 @@ this zero-dependency package will provide a browser-compatible version of the is
#### todo
- none

#### changelog for v2017.10.4
- npm publish 2017.10.4
- add cli-help doc to README.md
#### changelog for v2017.11.21
- npm publish 2017.11.21
- update build
- none

#### this package requires
Expand All @@ -77,13 +77,13 @@ this zero-dependency package will provide a browser-compatible version of the is
```shell
# example.sh

# this shell script will download and run a web demo of istanbul-lite as a standalone app
# this shell script will download and run a web-demo of istanbul-lite as a standalone app

# 1. download standalone app
curl -O https://kaizhu256.github.io/node-istanbul-lite/build..beta..travis-ci.org/app/assets.app.js
# 2. run standalone app
node ./assets.app.js
# 3. open a browser to http://127.0.0.1:8081 and play with the web demo
PORT=8081 node ./assets.app.js
# 3. open a browser to http://127.0.0.1:8081 and play with the web-demo
# 4. edit file assets.app.js to suit your needs
```

Expand All @@ -104,13 +104,13 @@ node ./assets.app.js
/*
example.js
this script will run a web demo of istanbul-lite
this script will run a web-demo of istanbul-lite
instruction
1. save this script as example.js
2. run the shell command:
$ npm install istanbul-lite && PORT=8081 node example.js
3. open a browser to http://127.0.0.1:8081 and play with the web demo
3. open a browser to http://127.0.0.1:8081 and play with the web-demo
4. edit this script to suit your needs
*/

Expand All @@ -121,7 +121,7 @@ instruction
bitwise: true,
browser: true,
maxerr: 8,
maxlen: 96,
maxlen: 100,
node: true,
nomen: true,
regexp: true,
Expand Down Expand Up @@ -298,32 +298,70 @@ instruction
<title>{{env.npm_package_name}} (v{{env.npm_package_version}})</title>\n\
<style>\n\
/*csslint\n\
box-model: false,\n\
box-sizing: false,\n\
universal-selector: false\n\
*/\n\
* {\n\
*,\n\
*:after,\n\
*:before {\n\
box-sizing: border-box;\n\
}\n\
body {\n\
background: #dde;\n\
font-family: Arial, Helvetica, sans-serif;\n\
margin: 2rem;\n\
margin: 0 40px;\n\
}\n\
body > * {\n\
margin-bottom: 1rem;\n\
body > a,\n\
body > button,\n\
body > div,\n\
body > input,\n\
body > pre,\n\
body > select,\n\
body > span,\n\
body > textarea {\n\
margin-bottom: 20px;\n\
}\n\
body > button {\n\
width: 20rem;\n\
}\n\
button {\n\
cursor: pointer;\n\
}\n\
@keyframes uiAnimateShake {\n\
100% {\n\
transform: translateX(0);\n\
}\n\
0%, 20%, 60% {\n\
transform: translateX(10px);\n\
}\n\
40%, 80% {\n\
transform: translateX(-10px);\n\
}\n\
}\n\
.uiAnimateShake {\n\
animation-duration: 500ms;\n\
animation-name: uiAnimateShake;\n\
}\n\
.uiAnimateSlide {\n\
overflow-y: hidden;\n\
transition: border-bottom 250ms, border-top 250ms, margin-bottom 250ms, margin-top 250ms, max-height 250ms, min-height 250ms, padding-bottom 250ms, padding-top 250ms;\n\
transition: max-height ease-in 250ms, min-height ease-in 250ms, padding-bottom ease-in 250ms, padding-top ease-in 250ms;\n\
}\n\
@keyframes uiAnimateSpin {\n\
0% { transform: rotate(0deg); }\n\
100% { transform: rotate(360deg); }\n\
}\n\
.uiAnimateSpin {\n\
animation: uiAnimateSpin 2s linear infinite;\n\
border: 6px solid #999;\n\
border-radius: 50%;\n\
border-top: 8px solid #7d7;\n\
display: inline-block;\n\
height: 25px;\n\
vertical-align: middle;\n\
width: 25px;\n\
}\n\
.utility2FooterDiv {\n\
margin-top: 20px;\n\
text-align: center;\n\
}\n\
.zeroPixel {\n\
Expand All @@ -348,13 +386,13 @@ textarea[readonly] {\n\
</style>\n\
</head>\n\
<body>\n\
<div id="ajaxProgressDiv1" style="background: #d00; height: 2px; left: 0; margin: 0; padding: 0; position: fixed; top: 0; transition: background 500ms, width 1500ms; width: 0%;"></div>\n\
<div id="ajaxProgressDiv1" style="background: #d00; height: 2px; left: 0; margin: 0; padding: 0; position: fixed; top: 0; transition: background 500ms, width 1500ms; width: 0%; z-index: 1;"></div>\n\
<script>\n\
/*jslint\n\
bitwise: true,\n\
browser: true,\n\
maxerr: 8,\n\
maxlen: 96,\n\
maxlen: 100,\n\
node: true,\n\
nomen: true,\n\
regexp: true,\n\
Expand Down Expand Up @@ -517,7 +555,7 @@ utility2-comment -->\n\
local.assetsDict['/assets.istanbul.js'] =
local.assetsDict['/assets.istanbul.js'] ||
local.fs.readFileSync(
local.istanbul.__dirname + '/lib.istanbul.js',
local.__dirname + '/lib.istanbul.js',
'utf8'
).replace((/^#!/), '//');
/* jslint-ignore-end */
Expand Down Expand Up @@ -601,7 +639,7 @@ utility2-comment -->\n\
"bin": {
"istanbul-lite": "lib.istanbul.js"
},
"description": "this zero-dependency package will provide a browser-compatible version of the istanbul (v0.4.5) coverage-tool",
"description": "this zero-dependency package will provide a browser-compatible version of the istanbul (v0.4.5) coverage-tool, with a working web-demo",
"devDependencies": {
"electron-lite": "kaizhu256/node-electron-lite#alpha",
"utility2": "kaizhu256/node-utility2#alpha"
Expand All @@ -618,6 +656,7 @@ utility2-comment -->\n\
"license": "MIT",
"main": "lib.istanbul.js",
"name": "istanbul-lite",
"nameAliasPublish": "istanbul-classic",
"nameLib": "istanbul",
"nameOriginal": "istanbul-lite",
"os": [
Expand All @@ -636,7 +675,7 @@ utility2-comment -->\n\
"start": "PORT=${PORT:-8080} utility2 start test.js",
"test": "PORT=$(utility2 shServerPortRandom) utility2 test test.js"
},
"version": "2017.10.4"
"version": "2017.11.21"
}
```

Expand Down
33 changes: 16 additions & 17 deletions lib.istanbul.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
bitwise: true,
browser: true,
maxerr: 8,
maxlen: 96,
maxlen: 100,
node: true,
nomen: true,
regexp: true,
Expand Down Expand Up @@ -229,11 +229,10 @@
file = file
.replace((/\bhtml\b/g), 'x-istanbul-html')
.replace((/<style>[\S\s]+?<\/style>/), function (match0) {
return match0
.replace((/\S.*?\{/g), function (match0) {
return 'x-istanbul-html ' + match0
.replace((/,/g), ', x-istanbul-html ');
});
return match0.replace((/\S.*?\{/g), function (match0) {
return 'x-istanbul-html ' +
match0.replace((/,/g), ', x-istanbul-html ');
});
})
.replace('position: fixed;', 'position: static;')
.replace('margin-top: 170px;', 'margin-top: 10px;');
Expand Down Expand Up @@ -343,8 +342,7 @@
local.coverageReportHtml = '';
local.coverageReportHtml += '<div class="coverageReportDiv">\n' +
'<h1>coverage-report</h1>\n' +
'<div ' +
'style="background: #fff; border: 1px solid #000; margin 0; padding: 0;">\n';
'<div style="background: #fff; border: 1px solid #000; margin 0; padding: 0;">\n';
local.writerData = '';
options.sourceStore = {};
options.writer = local.writer;
Expand Down Expand Up @@ -372,10 +370,11 @@
// edit coverage badge percent
.replace((/100.0/g), options.pct)
// edit coverage badge color
.replace((/0d0/g), ('0' + Math.round((100 - options.pct) * 2.21)
.toString(16)).slice(-2) +
('0' + Math.round(options.pct * 2.21).toString(16)).slice(-2) +
'00')
.replace(
(/0d0/g),
('0' + Math.round((100 - options.pct) * 2.21).toString(16)).slice(-2) +
('0' + Math.round(options.pct * 2.21).toString(16)).slice(-2) + '00'
)
);
}
console.log('created coverage file ' + options.dir + '/index.html');
Expand Down Expand Up @@ -2662,11 +2661,11 @@ local.templateCoverageBadgeSvg =
// add coverage hook to require
local._istanbul_moduleExtensionsJs = local._istanbul_module._extensions['.js'];
local._istanbul_module._extensions['.js'] = function (module, file) {
if (typeof file === 'string' &&
(file.indexOf(process.env.npm_config_mode_coverage_dir) === 0 || (
file.indexOf(process.cwd()) === 0 &&
file.indexOf(process.cwd() + '/node_modules/') !== 0
))) {
if (typeof file === 'string' && (
file.indexOf(process.env.npm_config_mode_coverage_dir) === 0 ||
(file.indexOf(process.cwd()) === 0 &&
file.indexOf(process.cwd() + '/node_modules/') !== 0)
)) {
module._compile(local.instrumentInPackage(
local.fs.readFileSync(file, 'utf8'),
file
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"bin": {
"istanbul-lite": "lib.istanbul.js"
},
"description": "this zero-dependency package will provide a browser-compatible version of the istanbul (v0.4.5) coverage-tool",
"description": "this zero-dependency package will provide a browser-compatible version of the istanbul (v0.4.5) coverage-tool, with a working web-demo",
"devDependencies": {
"electron-lite": "kaizhu256/node-electron-lite#alpha",
"utility2": "kaizhu256/node-utility2#alpha"
Expand All @@ -20,6 +20,7 @@
"license": "MIT",
"main": "lib.istanbul.js",
"name": "istanbul-lite",
"nameAliasPublish": "istanbul-classic",
"nameLib": "istanbul",
"nameOriginal": "istanbul-lite",
"os": [
Expand All @@ -38,5 +39,5 @@
"start": "PORT=${PORT:-8080} utility2 start test.js",
"test": "PORT=$(utility2 shServerPortRandom) utility2 test test.js"
},
"version": "2017.10.4"
"version": "2017.11.21"
}
15 changes: 7 additions & 8 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
bitwise: true,
browser: true,
maxerr: 8,
maxlen: 96,
maxlen: 100,
node: true,
nomen: true,
regexp: true,
Expand Down Expand Up @@ -510,13 +510,12 @@ factorial(100)
/*
* this function will test istanbulCoverageReportCreate's default handling-behavior
*/
options = [
local.env.npm_config_mode_coverage_merge = '';
local.testMock([
[local.istanbul, { coverageMerge: local.echo }],
// test $npm_config_mode_coverage_merge handling-behavior
[local.env, { npm_config_mode_coverage_merge: '1' }]
];
local.env.npm_config_mode_coverage_merge = '';
local.testMock(options, function (onError) {
], function (onError) {
/*jslint evil: true*/
// cleanup old coverage
if (local.modeJs === 'node') {
Expand Down Expand Up @@ -569,7 +568,7 @@ factorial(100)
local.global.__coverage__[file] = null;
}
});
onError();
onError(null, options);
}, onError);
};

Expand All @@ -581,7 +580,7 @@ factorial(100)
options.data = local.istanbul.instrumentSync('1', 'test.js');
// validate data
local.assert(options.data.indexOf(".s['1']++;1;\n") >= 0, options);
onError();
onError(null, options);
};
}());
switch (local.modeJs) {
Expand Down Expand Up @@ -638,7 +637,7 @@ local.assertJsonEqual(options.coverage1,
{"/test":{"b":{"1":[1,1]},"branchMap":{"1":{"line":2,"locations":[{"end":{"column":25,"line":2},"start":{"column":13,"line":2}},{"end":{"column":40,"line":2},"start":{"column":28,"line":2}}],"type":"cond-expr"}},"code":["(function () {","return arg ? __coverage__ : __coverage__;","}());"],"f":{"1":2},"fnMap":{"1":{"line":1,"loc":{"end":{"column":13,"line":1},"start":{"column":1,"line":1}},"name":"(anonymous_1)"}},"path":"/test","s":{"1":2,"2":2},"statementMap":{"1":{"end":{"column":5,"line":3},"start":{"column":0,"line":1}},"2":{"end":{"column":41,"line":2},"start":{"column":0,"line":2}}}}}
);
/* jslint-ignore-end */
onError();
onError(null, options);
};
break;
}
Expand Down

0 comments on commit 50e5c75

Please sign in to comment.