Skip to content

Commit

Permalink
refactor: added logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nejcm committed Sep 30, 2022
1 parent 2cf8d02 commit 4cf7c21
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
11 changes: 7 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions dist/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getBundleSizeDiff = exports.getFilesMap = exports.bundleSizeJson = exports.bundleSizeFile = exports.getFileSize = exports.buildGroupReport = exports.buildReport = void 0;
const core_1 = require("@actions/core");
const promises_1 = __importDefault(require("fs/promises"));
const glob_1 = __importDefault(require("glob"));
const path_1 = __importDefault(require("path"));
Expand Down Expand Up @@ -107,10 +108,10 @@ const getFilesMap = (path, options) => {
exports.getFilesMap = getFilesMap;
const getBundleSizeDiff = (paths, onlyDiff = false, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
const splited = paths.trim().split(',');
const result = splited.reduce((groupAcc, groupPath) => __awaiter(void 0, void 0, void 0, function* () {
const result = yield splited.reduce((groupAcc, groupPath) => __awaiter(void 0, void 0, void 0, function* () {
const fileMap = (0, exports.getFilesMap)(groupPath, options);
(0, core_1.info)(`Files: ${JSON.stringify(fileMap)}`);
let summary = '';
// TODO: run in paralel
const fileKeys = Object.keys(fileMap);
const groupReports = yield fileKeys.reduce((acc, key) => __awaiter(void 0, void 0, void 0, function* () {
const fullPath = path_1.default.join(basePaths.main, key);
Expand All @@ -137,6 +138,7 @@ const getBundleSizeDiff = (paths, onlyDiff = false, options = {}) => __awaiter(v
groupMemo.reports[groupPath] = groupReports;
return groupMemo;
}), Promise.resolve({ reports: {}, summary: '' }));
return yield result;
result.summary = result.summary.trim();
return result;
});
exports.getBundleSizeDiff = getBundleSizeDiff;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bundle-size-reporter-action",
"version": "1.2.3",
"version": "1.2.4",
"description": "Bundle size reporter",
"main": "dist/index.js",
"keywords": [
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const run = async (): Promise<void> => {
const { reports, summary = '' } = await getBundleSizeDiff(paths, onlyDiff);
setOutput('reports', reports);
setOutput('summary', summary);
info(`Summary:\n${summary}`);
info(`Bundle size action completed.`);
} catch (error: any) {
setFailed(error.message || error);
Expand Down
1 change: 0 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export const getBundleSizeDiff = async (
options: glob.IOptions = {},
): Promise<Response> => {
const splited = paths.trim().split(',');
info(`Paths: ${JSON.stringify(splited)}`);

const result = await splited.reduce<Promise<Response>>(
async (groupAcc, groupPath) => {
Expand Down

0 comments on commit 4cf7c21

Please sign in to comment.