diff --git a/package.json b/package.json index a18a513fb..2e9b31b7f 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,9 @@ "pre-commit": "pre-commit", "jest": { "testEnvironment": "node", - "setupFiles": ["./testSetup.js"] + "setupFiles": [ + "./testSetup.js" + ] }, "greenkeeper": { "ignore": [ @@ -63,6 +65,7 @@ "jest-validate": "^20.0.3", "listr": "^0.12.0", "lodash": "^4.17.4", + "log-symbols": "^2.0.0", "minimatch": "^3.0.0", "npm-which": "^3.0.1", "p-map": "^1.1.1", diff --git a/src/runScript.js b/src/runScript.js index 53c204d8f..71848d828 100644 --- a/src/runScript.js +++ b/src/runScript.js @@ -2,6 +2,7 @@ const chunk = require('lodash/chunk') const execa = require('execa') +const logSymbols = require('log-symbols') const pMap = require('p-map') const getConfig = require('./getConfig').getConfig const calcChunkSize = require('./calcChunkSize') @@ -47,16 +48,16 @@ module.exports = function runScript(commands, pathsToLint, packageJson, config) return pMap(filePathChunks, mapper, { concurrency }) .catch(err => { /* This will probably never be called. But just in case.. */ - throw new Error(`🚫 ${linter} got an unexpected error. + throw new Error(`${logSymbols.error} ${linter} got an unexpected error. ${err.message}`) }) .then(() => { - if (errors.length === 0) return `✅ ${linter} passed!` + if (errors.length === 0) return `${logSymbols.success} ${linter} passed!` const errStdout = errors.map(err => err.stdout).join('') const errStderr = errors.map(err => err.stderr).join('') - throw new Error(`🚫 ${linter} found some errors. Please fix them and try committing again. + throw new Error(`${logSymbols.error} ${linter} found some errors. Please fix them and try committing again. ${errStdout} ${errStderr}`) }) diff --git a/test/runScript-mock-pMap.spec.js b/test/runScript-mock-pMap.spec.js index 550eea322..e4c017ade 100644 --- a/test/runScript-mock-pMap.spec.js +++ b/test/runScript-mock-pMap.spec.js @@ -1,4 +1,5 @@ import pMapMock from 'p-map' +import logSymbols from 'log-symbols' import runScript from '../src/runScript' jest.mock('p-map') @@ -38,7 +39,7 @@ describe('runScript', () => { try { await res[0].task() } catch (err) { - expect(err.message).toMatch(`🚫 test got an unexpected error. + expect(err.message).toMatch(`${logSymbols.error} test got an unexpected error. Unexpected Error`) } }) diff --git a/test/runScript.spec.js b/test/runScript.spec.js index b835871f2..eea5947c5 100644 --- a/test/runScript.spec.js +++ b/test/runScript.spec.js @@ -1,6 +1,7 @@ /* eslint no-underscore-dangle: 0 */ import mockFn from 'execa' +import logSymbols from 'log-symbols' import runScript from '../src/runScript' jest.mock('execa') @@ -145,7 +146,7 @@ describe('runScript', () => { await taskPromise } catch (err) { expect(err.message) - .toMatch(`🚫 mock-fail-linter found some errors. Please fix them and try committing again. + .toMatch(`${logSymbols.error} mock-fail-linter found some errors. Please fix them and try committing again. ${linterErr.stdout} ${linterErr.stderr}`) }