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

Commit bb8e58b

Browse files
committed
fix: fix fs issue & improve error messages
1 parent b2ae52b commit bb8e58b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

packages/core/.npmignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*
2+
!/lib/**/*.js
3+
*.test.js

packages/core/src/index.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-console */
12
import zlib from 'zlib'
23
import { promisify } from 'util'
34
import path from 'path'
@@ -12,7 +13,9 @@ import { resolveConfig, getToken, getApiUrl } from './config'
1213
const gzip = promisify(zlib.gzip)
1314

1415
async function sizeAssets(webpackStats, { fileSystem = fs } = {}) {
15-
const readFile = promisify(fileSystem.readFile.bind(fileSystem))
16+
const readFile = promisify(
17+
fileSystem.readFile ? fileSystem.readFile.bind(fileSystem) : fs.readFile,
18+
)
1619
return Promise.all(
1720
webpackStats.assets.map(async asset => {
1821
const fullPath = path.join(webpackStats.outputPath, asset.name)
@@ -85,6 +88,17 @@ export async function uploadStats({
8588
config,
8689
})
8790
} catch (error) {
91+
if (
92+
error.response &&
93+
error.response.data &&
94+
error.response.data.error &&
95+
error.response.data.error.errors
96+
) {
97+
console.error('Invalid Bundle Analyzer config:')
98+
error.response.data.error.errors.forEach(message =>
99+
console.error(message),
100+
)
101+
}
88102
throw new Error(getErrorMessage(error))
89103
}
90104
}

0 commit comments

Comments
 (0)