Skip to content

Commit

Permalink
Update dependency yargs to v17 (#382)
Browse files Browse the repository at this point in the history
* Update dependency yargs to v17

* Fix coercion

* Add tests for coersion

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Ryan Zimmerman <opensrc@ryanzim.com>
  • Loading branch information
3 people committed Sep 24, 2021
1 parent 261aca2 commit 793dca6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lib/args.js
Expand Up @@ -13,7 +13,7 @@ const logo = `
//_____||___*_________*___||_____//
`

module.exports = require('yargs')
const { argv } = require('yargs')
.usage(
`${bold(red(logo))}
Usage:
Expand Down Expand Up @@ -88,10 +88,6 @@ Usage:
desc: 'Override the output file extension; for use with --dir',
type: 'string',
implies: 'dir',
coerce(ext) {
if (ext.indexOf('.') !== 0) return `.${ext}`
return ext
},
})
.option('base', {
desc: 'Mirror the directory structure relative to this path in the output directory, for use with --dir',
Expand Down Expand Up @@ -126,4 +122,8 @@ If there are multiple input files, the --dir or --replace option must be passed.
Input files may contain globs (e.g. src/**/*.css). If you pass an input directory, it will process all files in the directory and any subdirectories, respecting the glob pattern.
For more details, please see https://github.com/postcss/postcss-cli`
).argv
)

if (argv.ext && argv.ext.indexOf('.') !== 0) argv.ext = `.${argv.ext}`

module.exports = argv
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -29,7 +29,7 @@
"pretty-hrtime": "^1.0.3",
"read-cache": "^1.0.0",
"slash": "^3.0.0",
"yargs": "^16.0.0"
"yargs": "^17.0.0"
},
"devDependencies": {
"ava": "^3.1.0",
Expand Down
17 changes: 17 additions & 0 deletions test/ext.js
Expand Up @@ -23,3 +23,20 @@ test('--ext works', async (t) => {

t.truthy(await fs.pathExists(path.join(dir, 'a.css')))
})

test('--ext works with no leading dot', async (t) => {
const dir = tmp()

const { error, stderr } = await cli([
'test/fixtures/a.sss',
'--parser',
'sugarss',
'-d',
dir,
'--ext',
'css',
])
t.falsy(error, stderr)

t.truthy(await fs.pathExists(path.join(dir, 'a.css')))
})

0 comments on commit 793dca6

Please sign in to comment.