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

Commit

Permalink
fix(core): add file check script in travis build
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaLiPassion authored and mhevery committed Jan 10, 2018
1 parent 67e8178 commit 615a6c1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
27 changes: 27 additions & 0 deletions check-file-size.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
const fs = require('fs');

module.exports = function(config) {
let chkResult = true;
config.targets.forEach(target => {
if (target.checkTarget) {
try {
const stats = fs.statSync(target.path);
if (stats.size > target.limit) {
console.error(`file ${target.path} size over limit, limit is ${target.limit}, actual is ${stats.size}`);
chkResult = false;
}
} catch (err) {
console.error(`failed to get filesize: ${target.path}`);
chkResult = false;
}
}
});
return chkResult;
};
9 changes: 9 additions & 0 deletions file-size-limit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"targets": [
{
"path": "dist/zone.min.js",
"checkTarget": true,
"limit": 40000
}
]
}
11 changes: 11 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,14 @@ gulp.task('promisetest', ['build/zone-node.js'], (cb) => {
}
});
});

// check dist file size limitation
gulp.task('filesize', ['build'], (cb) => {
const checker = require('./check-file-size');
const result = checker(require('./file-size-limit.json'));
if (result) {
cb();
} else {
cb('check file size failed');
}
});

0 comments on commit 615a6c1

Please sign in to comment.