diff --git a/.babelrc b/.babelrc index 79c526af..2c226dfe 100644 --- a/.babelrc +++ b/.babelrc @@ -5,7 +5,8 @@ { "targets": { "node": "6" - } + }, + "loose": true } ] ], diff --git a/src/cli/__snapshots__/index.test.js.snap b/src/cli/__snapshots__/index.test.js.snap index 3cccb47d..6e0252f1 100644 --- a/src/cli/__snapshots__/index.test.js.snap +++ b/src/cli/__snapshots__/index.test.js.snap @@ -232,6 +232,21 @@ export default One; " `; +exports[`cli --tab-width 1`] = ` +"import React from \\"react\\"; + +const One = props => ( + + Rectangle 5 + + +); + +export default One; + +" +`; + exports[`cli --template 1`] = ` "import React from \\"react\\"; diff --git a/src/cli/index.js b/src/cli/index.js index 99b06a9f..ba2cf967 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -36,13 +36,15 @@ program .option( '-p, --precision ', '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 without id (svgo)') .option('--no-title', 'remove title tag (svgo)') .option( - '--tab-width', + '--tab-width ', '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)') diff --git a/src/cli/index.test.js b/src/cli/index.test.js index 7fc3a544..d07d1f5a 100644 --- a/src/cli/index.test.js +++ b/src/cli/index.test.js @@ -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() })