Skip to content

normalize seems to override coerce callback result #56

@rpl

Description

@rpl

It seems that when the two property are combined, normalize overrides the coerced value with the normalized version of the original value of the option.

Minimal nodejs snippet to reproduce the issue:

var yargs = require('yargs');
var path = require('path');

var argv = yargs.option('source-dir', {
  normalize: true,
  coerce: path.resolve
}).argv;

console.log("result", {
  sourceDir: argv.sourceDir,
  resolvedSourceDir: path.resolve(argv.sourceDir)
});
$ node test-normalize-coerce.js --source-dir ../src/../src
result { sourceDir: '../src',
  resolvedSourceDir: '/resolved/dir/src' }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions