mirror of
https://github.com/ryan-haskell/elm-spa.git
synced 2024-11-22 11:31:58 +03:00
handle npx elm compile error messages
This commit is contained in:
parent
0f8cc59757
commit
8b7e741e50
@ -137,8 +137,23 @@ const compileMainElm = (env : Environment) => async () => {
|
||||
.catch(colorElmError)
|
||||
}
|
||||
|
||||
const red = colors.RED
|
||||
const green = colors.green
|
||||
|
||||
const colorElmError = (err : string) => {
|
||||
const errors = JSON.parse(err).errors as Error[] || []
|
||||
let errors = []
|
||||
|
||||
try {
|
||||
errors = JSON.parse(err).errors as Error[] || []
|
||||
} catch (e) {
|
||||
return Promise.reject([
|
||||
`${red}Something went wrong with elm-spa.${reset}`,
|
||||
`Please report this entire error to ${green}https://github.com/ryannhg/elm-spa/issues${reset}`,
|
||||
`-----`,
|
||||
err,
|
||||
`-----`
|
||||
].join('\n\n'))
|
||||
}
|
||||
|
||||
const strIf = (str : string) => (cond : boolean) : string => cond ? str : ''
|
||||
const boldIf = strIf(bold)
|
||||
|
@ -2,5 +2,8 @@ import { exec } from 'child_process'
|
||||
|
||||
export const run = (cmd : string) : Promise<unknown> =>
|
||||
new Promise((resolve, reject) =>
|
||||
exec(cmd, (err, stdout, stderr) => err ? reject(stderr) : resolve(stdout))
|
||||
exec(cmd, (err, stdout, stderr) => err
|
||||
? reject(stderr.split('npm ERR!')[0] || stderr)
|
||||
: resolve(stdout)
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user