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

feat: Add overwrite option to download command #785

Merged
merged 3 commits into from
Oct 6, 2021

Conversation

jonassvalin
Copy link
Contributor

What?

I want the ability to run stencil download without being prompted about whether to overwrite local files. The goal is to easier be able to run download in my CI pipeline.

This is a conceptual pull requests thus far, I have not verified whether the functionality works exactly as intended. This particular command seemed to be untested, so I did not venture to add any tests.

If you have preferences for how this functionality could work different, please let me know or feel free to make changes.

@jonassvalin jonassvalin changed the title Add overwrite option to download command feat: Add overwrite option to download command Oct 2, 2021
@@ -25,21 +26,24 @@ const options = {
exclude: ['parsed', 'manifest.json', ...extraExclude],
apiHost: cliOptions.host,
channelId: cliOptions.channel_id,
overwrite: cliOptions.overwrite,
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is just a boolean, I would prefer more specific name, like skipOverwriteQuestion or omitOverwriteAsk.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this one isn't actually saying whether to ask the question, but is the actual answer to the question: Should we overwrite? Hence why it seems correct for it to just be called overwrite

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have refactored this to simply be a boolean, rather than a "Yes" or "No" string value

? [opts.overwrite]
: await inquirer.prompt([
{
message: `${'Warning'.yellow} -- overwrite local with remote ${overwriteType}?`,
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use when option to disable/enable question: https://github.com/SBoudrias/Inquirer.js#question

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for bringing this to my attention! I have refactored it accordingly.

Copy link
Contributor

@jairo-bc jairo-bc left a comment

Choose a reason for hiding this comment

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

Would be nice to have those comments addressed. Thank you!

@jonassvalin
Copy link
Contributor Author

@jairo-bc Thanks for your comments! I have tried to address them as best as I can.

I made an additional change, which is that I refactored the "overwrite question" to be a confirm, rather than a checkbox. It seemed strange that it was a checkbox since, if my understanding is correct, it's actually just a boolean question, "Should we overwrite the local files?".

The only downside I see with that change is that it will be a breaking change of how that prompt behaves.

@jonassvalin jonassvalin requested a review from jairo-bc October 6, 2021 07:59
@jairo-bc jairo-bc merged commit eb78444 into bigcommerce:master Oct 6, 2021
@jairo-bc jairo-bc mentioned this pull request Oct 6, 2021
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.

2 participants