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: don’t sort scripts when npm-run-all2 is installed #309

Merged
merged 1 commit into from
Jan 29, 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
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ const sortScripts = onObject((scripts, packageJson) => {
return name
})

if (!hasDevDependency('npm-run-all', packageJson)) {
if (
!hasDevDependency('npm-run-all', packageJson) &&
!hasDevDependency('npm-run-all2', packageJson)
) {
keys.sort()
}

Expand Down
17 changes: 17 additions & 0 deletions tests/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,20 @@ for (const field of ['scripts', 'betterScripts']) {
},
})
}

for (const field of ['scripts', 'betterScripts']) {
test(`${field} when npm-run-all2 is not a dev dependency`, macro.sortObject, {
value: { [field]: fixture },
expect: { [field]: expectAllSorted },
})
test(`${field} when npm-run-all2 is a dev dependency`, macro.sortObject, {
value: {
[field]: fixture,
devDependencies: { 'npm-run-all2': '^1.0.0' },
},
expect: {
[field]: expectPreAndPostSorted,
devDependencies: { 'npm-run-all2': '^1.0.0' },
},
})
}
Loading