Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit e511b67

Browse files
fix: getIndentationCharacter is not working when buffer is passed
1 parent 2caede5 commit e511b67

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: projectHelpers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const writePackageJson = (content, projectDir) => {
5454
}
5555

5656
const getIndentationCharacter = (jsonContent) => {
57-
const matches = jsonContent.match(/{\r*\n*(\W*)"/m);
57+
const matches = jsonContent && jsonContent.toString().match(/{\r*\n*(\W*)"/m);
5858
return matches && matches[1];
5959
}
6060

Diff for: projectHelpers.spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ describe('projectHelpers', () => {
1818
{
1919
testName: 'returns two spaces when file starts with two spaces',
2020
input: `{${twoSpaces}"abc": "1"${twoSpaces}}`,
21+
expectedResult: twoSpaces
22+
},
23+
{
24+
testName: 'returns two spaces when file starts with two spaces and binary content is passed',
25+
input: Buffer.from(`{${twoSpaces}"abc": "1"${twoSpaces}}`),
2126
expectedResult: twoSpaces
2227
},
2328
{

0 commit comments

Comments
 (0)