Skip to content

Commit

Permalink
fix: Unicode symbols compatibility on Windows (#248)
Browse files Browse the repository at this point in the history
Replace emojis with symbols from `log-symbols` since Windows doesn't support Emoji in CLIs ¯\_(ツ)_/¯
  • Loading branch information
luftywiranda13 authored and okonet committed Sep 7, 2017
1 parent a8a585a commit 49b11e4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -24,7 +24,9 @@
"pre-commit": "pre-commit",
"jest": {
"testEnvironment": "node",
"setupFiles": ["./testSetup.js"]
"setupFiles": [
"./testSetup.js"
]
},
"greenkeeper": {
"ignore": [
Expand Down Expand Up @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions src/runScript.js
Expand Up @@ -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')
Expand Down Expand Up @@ -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}`)
})
Expand Down
3 changes: 2 additions & 1 deletion 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')
Expand Down Expand Up @@ -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`)
}
})
Expand Down
3 changes: 2 additions & 1 deletion 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')
Expand Down Expand Up @@ -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}`)
}
Expand Down

0 comments on commit 49b11e4

Please sign in to comment.