Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ const summarize = require('./src/utils/summarize')

const run = async () => {
const results = analyse(markDuplicates(files))
const baseBranch = flags.baseBranch || 'main'

if (ci && branch === 'master' && !process.env.INTERNAL_SKIP_CACHE) {
if (ci && branch === baseBranch && !process.env.INTERNAL_SKIP_CACHE) {
await cache.save(results)
}
const cachedResults = await cache.read()

const summary = summarize(results, cachedResults)
const summary = summarize(results, cachedResults, { baseBranch })
cli.report(summary)

if (ci && flags.enableGitHubChecks) {
const summaryWithoutColors = summarize(results, cachedResults, {
colors: false,
baseBranch
})
await github.report(summaryWithoutColors)
}
Expand Down
5 changes: 5 additions & 0 deletions cli/src/pipeline/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ program
'--enable-github-checks',
'Enable checks on GitHub (needs installation)'
)
.option(
'--base-branch',
'Specify which branch to use as a baseline for comparison'
)
.option('-f, --files [files]', '(legacy) files to test against (dist/*.js)')
.option('-s, --max-size [maxSize]', '(legacy) maximum size threshold (3Kb)')
.option(
Expand Down Expand Up @@ -86,6 +90,7 @@ debug('selected config', files)
const flags = {
debug: program.debug,
enableGitHubChecks: program.enableGithubChecks,
baseBranch: program.baseBranch,
}

module.exports = { files, flags }
2 changes: 1 addition & 1 deletion cli/src/utils/summarize.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { Colors, WithoutColors } = require('./colors')

const summarize = (results, cachedResults = [], options = {}) => {
const colors = options.colors === false ? WithoutColors : Colors
const baseBranch = options.baseBranch || 'master'
const baseBranch = options.baseBranch

const status = results.status

Expand Down
2 changes: 1 addition & 1 deletion next-steps.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- [x] make checks opt in
- [x] improve title message if there's only one file
- [ ] pass ci build if failed check was added
- [ ] allow customisation of base branch, make main and master default
- [x] allow customisation of base branch, make main default
- [ ] rewrite readme
- [ ] match fuzzy rules from cache
- [ ] add cumulative diff with master in title [#22](https://github.com/siddharthkp/bundlesize2/issues/22)