Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 615a6c1

Browse files
JiaLiPassionmhevery
authored andcommitted
fix(core): add file check script in travis build
1 parent 67e8178 commit 615a6c1

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

Diff for: check-file-size.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
const fs = require('fs');
9+
10+
module.exports = function(config) {
11+
let chkResult = true;
12+
config.targets.forEach(target => {
13+
if (target.checkTarget) {
14+
try {
15+
const stats = fs.statSync(target.path);
16+
if (stats.size > target.limit) {
17+
console.error(`file ${target.path} size over limit, limit is ${target.limit}, actual is ${stats.size}`);
18+
chkResult = false;
19+
}
20+
} catch (err) {
21+
console.error(`failed to get filesize: ${target.path}`);
22+
chkResult = false;
23+
}
24+
}
25+
});
26+
return chkResult;
27+
};

Diff for: file-size-limit.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"targets": [
3+
{
4+
"path": "dist/zone.min.js",
5+
"checkTarget": true,
6+
"limit": 40000
7+
}
8+
]
9+
}

Diff for: gulpfile.js

+11
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,14 @@ gulp.task('promisetest', ['build/zone-node.js'], (cb) => {
410410
}
411411
});
412412
});
413+
414+
// check dist file size limitation
415+
gulp.task('filesize', ['build'], (cb) => {
416+
const checker = require('./check-file-size');
417+
const result = checker(require('./file-size-limit.json'));
418+
if (result) {
419+
cb();
420+
} else {
421+
cb('check file size failed');
422+
}
423+
});

0 commit comments

Comments
 (0)