Skip to content

Commit a863280

Browse files
authored
fix: fix tabWidth option (#49)
Closes #33
1 parent dfecd39 commit a863280

4 files changed

Lines changed: 26 additions & 3 deletions

File tree

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
{
66
"targets": {
77
"node": "6"
8-
}
8+
},
9+
"loose": true
910
}
1011
]
1112
],

src/cli/__snapshots__/index.test.js.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,21 @@ export default One;
232232
"
233233
`;
234234

235+
exports[`cli --tab-width 1`] = `
236+
"import React from \\"react\\";
237+
238+
const One = props => (
239+
<svg width={48} height={1} viewBox=\\"0 0 48 1\\" {...props}>
240+
<title>Rectangle 5</title>
241+
<path d=\\"M0 0h48v1H0z\\" fill=\\"#063855\\" fillRule=\\"evenodd\\" />
242+
</svg>
243+
);
244+
245+
export default One;
246+
247+
"
248+
`;
249+
235250
exports[`cli --template 1`] = `
236251
"import React from \\"react\\";
237252

src/cli/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ program
3636
.option(
3737
'-p, --precision <value>',
3838
'set the number of digits in the fractional part (svgo)',
39+
parseInt,
3940
)
4041
.option('--ids', 'keep ids within the svg (svgo)')
4142
.option('--keep-useless-defs', 'keep elements of <defs> without id (svgo)')
4243
.option('--no-title', 'remove title tag (svgo)')
4344
.option(
44-
'--tab-width',
45+
'--tab-width <value>',
4546
'specify the number of spaces by indentation-level (prettier)',
47+
parseInt,
4648
)
4749
.option('--use-tabs', 'indent lines with tabs instead of spaces (prettier)')
4850
.option('--no-semi', 'remove semi-colons (prettier)')

src/cli/index.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ describe('cli', () => {
6464
})
6565

6666
it('--precision', async () => {
67-
const [stdout] = await exec('bin/svgr --precision 1 __fixtures__/one.svg')
67+
const [stdout] = await exec('bin/svgr --precision 10 __fixtures__/one.svg')
68+
expect(stdout).toMatchSnapshot()
69+
})
70+
71+
it('--tab-width', async () => {
72+
const [stdout] = await exec('bin/svgr --tab-width 4 __fixtures__/one.svg')
6873
expect(stdout).toMatchSnapshot()
6974
})
7075

0 commit comments

Comments
 (0)