Skip to content

Commit 6862b1a

Browse files
committed
fix: prev
1 parent a484961 commit 6862b1a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scripts/compare-size.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ async function renderFiles() {
3737
const currPath = path.resolve(currDir, file)
3838
const prevPath = path.resolve(prevDir, file)
3939

40-
let curr
41-
if (existsSync(currPath)) curr = await importJSON(currPath)
42-
let prev
43-
if (existsSync(prevPath)) prev = await importJSON(prevPath)
44-
40+
const curr = await importJSON(currPath)
41+
const prev = await importJSON(prevPath)
4542
const fileName = curr?.file || prev?.file
4643

4744
if (!curr) {
@@ -79,7 +76,9 @@ async function processExports() {
7976
const curr = await importJSON(path.resolve(currDir, '_exports.json'))
8077
const prev = await importJSON(path.resolve(prevDir, '_exports.json'))
8178
output += '\n### Exports\n\n'
82-
output += renderExports(curr, prev)
79+
if (prev) {
80+
output += renderExports(curr, prev)
81+
}
8382
output += `\n\n<details>\n<summary>Show full exports</summary>\n\n${renderExports(
8483
curr
8584
)}\n\n</details>\n\n`
@@ -123,6 +122,7 @@ function renderExports(exports, prev) {
123122
* @param {string} path
124123
*/
125124
async function importJSON(path) {
125+
if (!existsSync(path)) return undefined
126126
return (await import(path, { assert: { type: 'json' } })).default
127127
}
128128

0 commit comments

Comments
 (0)