Skip to content

Commit

Permalink
fix: fix tabWidth option (#49)
Browse files Browse the repository at this point in the history
Closes #33
  • Loading branch information
gregberge committed Jan 31, 2018
1 parent dfecd39 commit a863280
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Expand Up @@ -5,7 +5,8 @@
{
"targets": {
"node": "6"
}
},
"loose": true
}
]
],
Expand Down
15 changes: 15 additions & 0 deletions src/cli/__snapshots__/index.test.js.snap
Expand Up @@ -232,6 +232,21 @@ export default One;
"
`;

exports[`cli --tab-width 1`] = `
"import React from \\"react\\";
const One = props => (
<svg width={48} height={1} viewBox=\\"0 0 48 1\\" {...props}>
<title>Rectangle 5</title>
<path d=\\"M0 0h48v1H0z\\" fill=\\"#063855\\" fillRule=\\"evenodd\\" />
</svg>
);
export default One;
"
`;

exports[`cli --template 1`] = `
"import React from \\"react\\";
Expand Down
4 changes: 3 additions & 1 deletion src/cli/index.js
Expand Up @@ -36,13 +36,15 @@ program
.option(
'-p, --precision <value>',
'set the number of digits in the fractional part (svgo)',
parseInt,
)
.option('--ids', 'keep ids within the svg (svgo)')
.option('--keep-useless-defs', 'keep elements of <defs> without id (svgo)')
.option('--no-title', 'remove title tag (svgo)')
.option(
'--tab-width',
'--tab-width <value>',
'specify the number of spaces by indentation-level (prettier)',
parseInt,
)
.option('--use-tabs', 'indent lines with tabs instead of spaces (prettier)')
.option('--no-semi', 'remove semi-colons (prettier)')
Expand Down
7 changes: 6 additions & 1 deletion src/cli/index.test.js
Expand Up @@ -64,7 +64,12 @@ describe('cli', () => {
})

it('--precision', async () => {
const [stdout] = await exec('bin/svgr --precision 1 __fixtures__/one.svg')
const [stdout] = await exec('bin/svgr --precision 10 __fixtures__/one.svg')
expect(stdout).toMatchSnapshot()
})

it('--tab-width', async () => {
const [stdout] = await exec('bin/svgr --tab-width 4 __fixtures__/one.svg')
expect(stdout).toMatchSnapshot()
})

Expand Down

0 comments on commit a863280

Please sign in to comment.