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

Commit

Permalink
fix: fix fs issue & improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Sep 16, 2019
1 parent b2ae52b commit bb8e58b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/core/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
!/lib/**/*.js
*.test.js
16 changes: 15 additions & 1 deletion packages/core/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import zlib from 'zlib'
import { promisify } from 'util'
import path from 'path'
Expand All @@ -12,7 +13,9 @@ import { resolveConfig, getToken, getApiUrl } from './config'
const gzip = promisify(zlib.gzip)

async function sizeAssets(webpackStats, { fileSystem = fs } = {}) {
const readFile = promisify(fileSystem.readFile.bind(fileSystem))
const readFile = promisify(
fileSystem.readFile ? fileSystem.readFile.bind(fileSystem) : fs.readFile,
)
return Promise.all(
webpackStats.assets.map(async asset => {
const fullPath = path.join(webpackStats.outputPath, asset.name)
Expand Down Expand Up @@ -85,6 +88,17 @@ export async function uploadStats({
config,
})
} catch (error) {
if (
error.response &&
error.response.data &&
error.response.data.error &&
error.response.data.error.errors
) {
console.error('Invalid Bundle Analyzer config:')
error.response.data.error.errors.forEach(message =>
console.error(message),
)
}
throw new Error(getErrorMessage(error))
}
}

0 comments on commit bb8e58b

Please sign in to comment.