Skip to content

Commit

Permalink
🐛 Prevent encoding utf-8 chars in README (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
zizizi17 authored and kefranabg committed Jul 5, 2019
1 parent 0877ce0 commit 8059756
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@
"code",
"test"
]
},
{
"login": "zizizi17",
"name": "Sasha Semanyuk",
"avatar_url": "https://avatars0.githubusercontent.com/u/10571073?v=4",
"profile": "https://github.com/zizizi17",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ Feel free to check [issues page](https://github.com/kefranabg/readme-md-generato
<td align="center"><a href="https://github.com/samit4me"><img src="https://avatars3.githubusercontent.com/u/3248531?v=4" width="75px;" alt="Samuel Sharpe"/><br /><sub><b>Samuel Sharpe</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=samit4me" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/apatrascu"><img src="https://avatars3.githubusercontent.com/u/1193770?v=4" width="75px;" alt="Alecsandru Patrascu"/><br /><sub><b>Alecsandru Patrascu</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=apatrascu" title="Code">💻</a></td>
<td align="center"><a href="http://milad.nekofar.com"><img src="https://avatars3.githubusercontent.com/u/147401?v=4" width="75px;" alt="Milad Nekofar"/><br /><sub><b>Milad Nekofar</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=nekofar" title="Code">💻</a> <a href="https://github.com/kefranabg/readme-md-generator/commits?author=nekofar" title="Tests">⚠️</a> <a href="#ideas-nekofar" title="Ideas, Planning, & Feedback">🤔</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/hgb123"><img src="https://avatars0.githubusercontent.com/u/18468577?v=4" width="75px;" alt="Bao Ho"/><br /><sub><b>Bao Ho</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=hgb123" title="Code">💻</a> <a href="https://github.com/kefranabg/readme-md-generator/commits?author=hgb123" title="Tests">⚠️</a></td>
<td align="center"><a href="https://github.com/zizizi17"><img src="https://avatars0.githubusercontent.com/u/10571073?v=4" width="75px;" alt="Sasha Semanyuk"/><br /><sub><b>Sasha Semanyuk</b></sub></a><br /><a href="https://github.com/kefranabg/readme-md-generator/commits?author=zizizi17" title="Code">💻</a></td>
</tr>
</table>

Expand Down
4 changes: 2 additions & 2 deletions src/readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const ora = require('ora')
const { promisify } = require('util')
const getYear = require('date-fns/get_year')
const fs = require('fs')
const { isNil } = require('lodash')
const { isNil, unescape } = require('lodash')

const chooseTemplate = require('./choose-template')

Expand All @@ -18,7 +18,7 @@ const writeReadme = async readmeContent => {
const spinner = ora('Creating README').start()

try {
await promisify(fs.writeFile)(README_PATH, readmeContent)
await promisify(fs.writeFile)(README_PATH, unescape(readmeContent))
spinner.succeed('README created')
} catch (err) {
spinner.fail('README creation fail')
Expand Down
4 changes: 2 additions & 2 deletions src/readme.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ describe('readme', () => {
})

it('should call writeFile with correct parameters', async () => {
const readmeContent = 'content'
const readmeContent = 'John &amp; Bryan'
fs.writeFile = jest.fn((_, __, cb) => cb(null, 'done'))

await writeReadme(readmeContent)

expect(fs.writeFile).toHaveBeenCalledTimes(1)
expect(fs.writeFile.mock.calls[0][0]).toBe(README_PATH)
expect(fs.writeFile.mock.calls[0][1]).toBe(readmeContent)
expect(fs.writeFile.mock.calls[0][1]).toBe('John & Bryan')
})
})

Expand Down

0 comments on commit 8059756

Please sign in to comment.