Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename --temp-directory option to --temp-dir #897

Merged
merged 3 commits into from Aug 27, 2018

Conversation

AndrewFinlay
Copy link
Contributor

This change makes the option naming consistent using the form --*-dir, fixes #895

Deprecates the option name --temp-directory in favour of --temp-dir. --temp-directory has been demoted to a yargs alias of --temp-dir, so it will still work with existing projects. I've updated the docs and changed the package.json test scripts to use the newer form.

I'm a little unsure of how tests should work for this, I've modified the package.json tests to use the new form, but then that doesn't test that the deprecated form still works, thoughts?

Deprecates the option name --temp-directory in favour of --temp-dir
--temp-directory has been demoted to a yargs alias of --temp-dir
This change makes the option naming consistent using the form --*-dir
Copy link
Member

@JaKXz JaKXz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense, I like ubiquitous language where we can get it :) thanks for your contribution!

@bcoe or @coreyfarrell I'd push the button but I'll leave it to you two in case you have more yargsish feedback.

@JaKXz JaKXz requested a review from coreyfarrell August 9, 2018 18:09
@coreyfarrell
Copy link
Member

One comment, as is --temp-directory will still be shown in nyc --help. I think this could be hidden by using a separate option for temp-directory with no describe or default, instead of making it an alias for temp-dir. Then when using the option you'd do this._tempDirectory = config.tempDir || config.tempDirectory || './.nyc_output'.

As for actually merging this change, I'd like to wait until we've released nyc@13 as latest. I'm planning for that release to happen early next week.

@AndrewFinlay
Copy link
Contributor Author

@coreyfarrell - I've run a quick test on the requested changes to the option structure,
the help output goes from:

--temp-dir, --temp-directory directory to output raw coverage information to
[default: "./.nyc_output"]

to

--temp-dir directory to output raw coverage information to
[default: "./.nyc_output"]
--temp-directory

with code:

    .option('temp-dir', {
      describe: 'directory to output raw coverage information to',
      default: './.nyc_output',
      global: false
    })
    .option('temp-directory', {
      global: false
    })

Not sure if this is what you're after.

Is there a better way to handle deprecation in yargs?

@coreyfarrell
Copy link
Member

Ah sorry I'm still not very good with yargs, thanks for double-checking my idea. I was looking for the old option to be excluded completely from the help screen. Looks like you need to add hidden: true to the options of the separate temp-directory to do that.

I'm not aware of anything in yargs specifically to help with specifying deprecated aliases, that would be neat if we could add hiddenAlias: 'temp-directory' to the temp-dir option.

@AndrewFinlay
Copy link
Contributor Author

The hidden flag works well, thanks

@AndrewFinlay
Copy link
Contributor Author

Regarding yargs, a hiddenDeprecated: 'temp-directory' that shouted a deprecation warning when it sees a 'temp-directory' would be nicer!

Copy link
Member

@coreyfarrell coreyfarrell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Sorry for the delay I've been quite busy the past couple weeks. As soon as I have time I'll be publishing nyc@13 to latest on npm, once that's done I'll be ready to merge this.

Thanks for the contribution and addressing my comments!

@coreyfarrell
Copy link
Member

Regarding yargs, a hiddenDeprecated: 'temp-directory' that shouted a deprecation warning when it sees a 'temp-directory' would be nicer!

I agree it would be nice if yargs had that kind of support but I feel like silent deprecation is best for this specific option. We'll never reuse temp-directory for any other purpose so the deprecated option can just remain. I don't see any reason to projects by printing an unexpected warning when temp-directory is set.

@jorgebucaran
Copy link

@AndrewFinlay @coreyfarrell I just realized that #906 is similar to this PR. Whether you decide to rename --temp-directory to --temp-dir or not, would you please consider adding a short (single-letter) alias to the directive like -t in #906.

@AndrewFinlay
Copy link
Contributor Author

@coreyfarrell Can add this if needed.

@jorgebucaran
Copy link

jorgebucaran commented Aug 22, 2018

@AndrewFinlay Could you please go ahead? I'll close my PR then.

Oops, I missed the silent deprecation of temp-directory in the report and merge commands, fixed now.
@coreyfarrell coreyfarrell merged commit ccf42df into istanbuljs:master Aug 27, 2018
@coreyfarrell
Copy link
Member

Thanks for the patch @AndrewFinlay, merged.

@AndrewFinlay AndrewFinlay deleted the new-aliases branch August 28, 2018 04:44
@simlu
Copy link

simlu commented Oct 19, 2018

So this was clearly a breaking change... :( See #927

@AndrewFinlay
Copy link
Contributor Author

AndrewFinlay commented Oct 19, 2018

Hi Simlu,

This wasn't intended to be a breaking change, I thought I'd left the old command intact to prevent any breaks but obviously not the case. I'll take a look at it sometime soon, sorry for the inconvenience.

After having a quick look, at a guess I'd say that the default for tempDir is overriding your value for tempDirectory. Will try and put something together tomorrow.

Andrew

@simlu
Copy link

simlu commented Oct 19, 2018

@AndrewFinlay Cheers and thank you! Much apreachiated!

@coreyfarrell
Copy link
Member

@AndrewFinlay Looking at the patch again I suspect this may be due to our leaving a default value in yargs for temp-dir. This means that the legacy option can never be used because config.tempDir is always set:

  this._tempDirectory = config.tempDir || config.tempDirectory || './.nyc_output'

@simlu As Andrew mentioned the intent was that temp-directory would continue to work (in fact I don't intend to remove it just leave it undocumented).

@AndrewFinlay
Copy link
Contributor Author

See #928

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consistent naming for *-directory options
5 participants