Skip to content

Commit

Permalink
feat: don’t sort scripts when npm-run-all2 is installed (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
kachkaev committed Jan 29, 2024
1 parent 93a1cbc commit 542d8ba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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' },
},
})
}

0 comments on commit 542d8ba

Please sign in to comment.