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

fix: invalid scripts warning fixed for undefined scripts #102

Merged
merged 1 commit into from
May 23, 2024

Conversation

milaninfy
Copy link
Contributor

Fixes npm/cli#7127

@milaninfy milaninfy marked this pull request as ready for review May 22, 2024 15:38
@milaninfy milaninfy requested a review from a team as a code owner May 22, 2024 15:38
lib/normalize.js Outdated
@@ -264,7 +264,8 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
}
}
} else {
changes?.push(`Removed invalid "scripts"`)
// it only makes sense to fix if package.json has scripts field
data.scripts && changes?.push(`Removed invalid "scripts"`)
Copy link
Member

@wraithgar wraithgar May 22, 2024

Choose a reason for hiding this comment

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

Let's make this an else if statement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I see some other scenarios as well that I'll cover in next changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These changes were not respecting false values like null, 0 or ''. Instead modified top if condition to check if package has scripts then only do the updates.

@milaninfy milaninfy force-pushed the mm/invalid-script-warning-fix branch from d7ae3c6 to dcf39ad Compare May 22, 2024 20:19
test/fix.js Show resolved Hide resolved
@wraithgar wraithgar merged commit 191b521 into npm:main May 23, 2024
23 checks passed
@github-actions github-actions bot mentioned this pull request May 23, 2024
wraithgar pushed a commit that referenced this pull request May 29, 2024
🤖 I have created a release *beep* *boop*
---


## [5.1.1](v5.1.0...v5.1.1)
(2024-05-28)

### Bug Fixes

*
[`54756d2`](54756d2)
[#105](#105) apply `securePath`
to package bin (#105) (@antongolub)
*
[`46c563b`](46c563b)
add `normalizePackageMan` helper (#100) (@antongolub)
*
[`a974274`](a974274)
prevent `directory.man` referencing outside the package root (#104)
(@antongolub)
*
[`191b521`](191b521)
[#102](#102) invalid scripts
warning fixed for undefined scripts (#102) (@milaninfy)

### Chores

*
[`45a2937`](45a2937)
[#98](#98) bump
@npmcli/template-oss to 4.22.0 (@lukekarrys)
*
[`90863c1`](90863c1)
[#98](#98) postinstall for
dependabot template-oss PR (@lukekarrys)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@milaninfy milaninfy deleted the mm/invalid-script-warning-fix branch August 26, 2024 19:26
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.

[BUG] npm pkg fix does not fix invalid scripts warning.
3 participants