Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix unicode symbols compatibility on Windows #248

Merged
merged 2 commits into from
Sep 7, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pMap from 'p-map'
import logSymbols from 'log-symbols'
import runScript from '../src/runScript'

jest.mock('p-map', () => jest.fn(() => Promise.resolve(true)))
Expand Down Expand Up @@ -32,7 +33,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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree! do it in this PR or on separate PR?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luftywiranda13 doesn't matter to me TBH.

@sudo-suhas could you help with those examples and create a PR that would "fix" them before this one is merged?

Copy link
Collaborator

@sudo-suhas sudo-suhas Sep 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit swamped at the moment. Trying to finish something at work. I can do it tomorrow. I think I'd prefer optimising jest related things in a separate PR after all the changes I have in the pipeline:

  • eslint-plugin-lodash
  • fix failing tests on windows
  • rebase dedent PR
  • getConfig - _normalized property
  • try pify

edit: 'fix failing tests on windows' takes highest priority. I actually can't run tests for my changes otherwise. And gotta make it all green 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on pify 👍

Unexpected Error`)
}
})
Expand Down
3 changes: 2 additions & 1 deletion test/runScript.spec.js
Original file line number Diff line number Diff line change
@@ -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 @@ -146,7 +147,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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${linteErr.stdout}
${linteErr.stderr}`)
}
Expand Down