Skip to content

Commit ebb112f

Browse files
author
Leo Vo
committed
Include coverage.
1 parent 08fa37b commit ebb112f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+10122
-727
lines changed

.angular-cli.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@
4848
}
4949
],
5050
"test": {
51+
"codeCoverage": {
52+
"exclude": [
53+
"src/polyfills.ts",
54+
"**/test.ts",
55+
"src/testing/*.*"
56+
]
57+
},
5158
"karma": {
5259
"config": "./karma.conf.js"
5360
}
@@ -56,4 +63,4 @@
5663
"styleExt": "scss",
5764
"component": {}
5865
}
59-
}
66+
}

.travis.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,44 @@
1+
#
2+
# Configuration
3+
#
4+
15
sudo: required
26
dist: trusty
7+
8+
notifications:
9+
email: true
10+
311
addons:
412
apt:
513
sources:
614
- google-chrome
715
packages:
816
- google-chrome-stable
17+
918
language: node_js
1019
node_js:
1120
- 6
21+
22+
branches:
23+
only:
24+
- master
25+
26+
#
27+
# Build Lifecycle:
28+
#
29+
30+
install:
31+
- npm install
32+
1233
before_script:
1334
- export DISPLAY=:99.0
1435
- sh -e /etc/init.d/xvfb start
15-
install:
16-
- npm install
36+
1737
script:
1838
- npm run lint
1939
- npm run test-ci
20-
- npm run e2e
40+
- npm run e2e
41+
42+
after_success:
43+
# Send coverage info off to cloud ppl
44+
- ./node_modules/.bin/codecov

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Place your settings in this file to overwrite the default settings
2+
{
3+
"typescript.check.tscVersion": true,
4+
"files.autoSave": "off",
5+
"eslint.enable": false
6+
}

gulpfile.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
const path = require('path');
2+
const gulp = require('gulp');
3+
const through = require('through2');
4+
const sass = require('node-sass');
5+
const fs = require('fs');
6+
7+
const paths = {
8+
src: 'src/lib',
9+
dist: 'dist/lib'
10+
}
11+
12+
gulp.task('inline', function () {
13+
const globs = [
14+
path.join(paths.dist, '**', '*.js'),
15+
];
16+
gulp.src(globs).pipe(through.obj((file, encode, callback) => {
17+
const filePath = file.path;
18+
19+
function resolveUrl(url) {
20+
return path.join(paths.src, url);
21+
}
22+
23+
function inlineTemplate(content) {
24+
return content.replace(/templateUrl:\s*'([^']+?\.html)'/g, (matchers, templateUrl) => {
25+
const templateFile = resolveUrl(templateUrl);
26+
const templateContent = fs.readFileSync(templateFile, encode);
27+
const shortenedTemplate = templateContent
28+
.replace(/([\n\r]\s*)+/gm, ' ');
29+
return `template: '${shortenedTemplate}'`;
30+
});
31+
}
32+
33+
function inlineStyles(content) {
34+
return content.replace(/styleUrls:\s*(\[[\s\S]*?\])/gm, (matchers, styleUrls) => {
35+
const urls = eval(styleUrls);
36+
return 'styles: ['
37+
+ urls.map(styleUrl => {
38+
const styleFile = resolveUrl(styleUrl);
39+
let styleContent = fs.readFileSync(styleFile, encode);
40+
if (/\.(scss)$/i.test(styleUrl)) {
41+
styleContent = compileSass(styleContent, styleFile);
42+
}
43+
const shortenedStyle = styleContent
44+
.replace(/([\n\r]\s*)+/gm, ' ');
45+
return `'${shortenedStyle}'`;
46+
}).join(',\n') + ']';
47+
});
48+
}
49+
50+
function compileSass(content, file) {
51+
const result = sass.renderSync({
52+
data: content,
53+
file: file,
54+
outputStyle: 'compact'
55+
});
56+
return result.css.toString();
57+
}
58+
59+
function removeModuleId(content) {
60+
return content.replace(/\s*moduleId:\s*module\.id\s*,?\s*/gm, '');
61+
}
62+
63+
function inline(content) {
64+
return [
65+
inlineTemplate,
66+
inlineStyles,
67+
removeModuleId
68+
].reduce((content, fn) => fn(content), content);
69+
}
70+
71+
if (/\.(component.js)$/i.test(filePath)) {
72+
let fileContent = file.contents.toString();
73+
fileContent = inline(fileContent);
74+
file.contents = new Buffer(fileContent);
75+
}
76+
77+
return callback(null, file);
78+
})).pipe(gulp.dest(paths.dist));
79+
});
80+
81+
gulp.task('default', ['inline']);

karma.conf.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,14 @@ module.exports = function (config) {
1515
client:{
1616
clearContext: false // leave Jasmine Spec Runner output visible in browser
1717
},
18-
files: [
19-
{ pattern: './src/test.ts', watched: false }
20-
],
21-
preprocessors: {
22-
'./src/test.ts': ['@angular/cli']
23-
},
24-
mime: {
25-
'text/x-typescript': ['ts','tsx']
26-
},
2718
coverageIstanbulReporter: {
2819
reports: [ 'html', 'lcovonly' ],
2920
fixWebpackSourcePaths: true
3021
},
3122
angularCli: {
3223
environment: 'dev'
3324
},
34-
reporters: config.angularCli && config.angularCli.codeCoverage
35-
? ['progress', 'coverage-istanbul']
36-
: ['progress', 'kjhtml'],
25+
reporters: ['progress', 'kjhtml'],
3726
port: 9876,
3827
colors: true,
3928
logLevel: config.LOG_INFO,

0 commit comments

Comments
 (0)