-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add --fix
CLI option
#367
Add --fix
CLI option
#367
Conversation
9d26824
to
ba2121a
Compare
index.js
Outdated
@@ -55,6 +57,7 @@ async function run(rootDir, options = {}) { | |||
log(' 👏 No unused translations were found!'); | |||
} else { | |||
log(` ⚠️ Found ${chalk.bold.yellow(unusedTranslations.size)} unused translations!`); | |||
log(' use --fix to remove all unused translations'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log(' use --fix to remove all unused translations'); | |
log(' You can use --fix to remove all unused translations.'); |
so that this aligns a little better :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I guess we should only log this line if shouldFix
is not true?
index.js
Outdated
@@ -13,6 +13,8 @@ const YAML = require('yaml'); | |||
|
|||
async function run(rootDir, options = {}) { | |||
let log = options.log || console.log; | |||
let writeToFile = options.writeToFile || fs.writeFileSync; | |||
let shouldFix = process.argv.includes('--fix'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to pass fix: true/false
in as one of the options
. That way we don't rely on the global process.argv
state and this run()
function stays reusable. It also means you don't have to use the process.argv.push('--fix')
hack below 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like this?
let shouldFix = process.argv.includes('--fix'); | |
let shouldFix = options.fix || process.argv.includes('--fix'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking more like this:
let shouldFix = process.argv.includes('--fix'); | |
let shouldFix = options.fix ?? false; |
and then in bin/cli.js
we use run(rootDir, { fix: process.argv.includes('--fix') })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR add a --fix option when running ember-intl-analyzer that should remove all unused translations whether they are whole keys or nested.
This is the first draft
Todo: