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 a --fix option #94

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ Use [installed-check-core](https://github.com/voxpelli/node-installed-check-core
* `--ignore-dev` / `-d` – if set then dev dependencies won't be included in the non-version checks.
* `--strict` / `-s` – treats warnings as errors

## Fix options
* `--fix` – tries to apply all suggestions and write them back to disk

## Workspace options

* `--no-include-workspace-root` – excludes the workspace root package. Negated equivalent of npm's [`--include-workspace-root`](https://docs.npmjs.com/cli/v10/commands/npm-run-script#include-workspace-root)
Expand Down
7 changes: 6 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const cli = meow(`
-d, --ignore-dev Excludes dev dependencies from non-version checks
-s, --strict Treat warnings as errors

Fix options
--fix Tries to apply all suggestions and write them back to disk

Workspace options
--no-include-workspace-root Will exclude the workspace root package
--no-workspaces Will exclude workspace packages
Expand All @@ -45,6 +48,7 @@ const cli = meow(`
engineCheck: { shortFlag: 'e', type: 'boolean' },
engineIgnore: { type: 'string', isMultiple: true },
engineNoDev: { type: 'boolean' },
fix: { type: 'boolean' },
ignore: { shortFlag: 'i', type: 'string', isMultiple: true },
ignoreDev: { shortFlag: 'd', type: 'boolean' },
includeWorkspaceRoot: { type: 'boolean', 'default': true },
Expand All @@ -69,6 +73,7 @@ const {
engineCheck,
engineIgnore, // deprecated
engineNoDev, // deprecated
fix = false,
includeWorkspaceRoot,
peerCheck,
strict,
Expand Down Expand Up @@ -129,7 +134,7 @@ if (debug) {
}

try {
const result = await installedCheck(checks, lookupOptions, checkOptions);
const result = await installedCheck(checks, lookupOptions, { ...checkOptions, fix });

if (verbose && result.warnings.length) {
console.log('\n' + chalk.bgYellow.black('Warnings:') + '\n\n' + result.warnings.join('\n') + '\n');
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"chalk": "^5.3.0",
"installed-check-core": "^8.2.3",
"installed-check-core": "^8.3.0",
"meow": "^12.1.1",
"pony-cause": "^2.1.10",
"version-guard": "^1.1.1"
Expand Down