Skip to content

Commit ccbc536

Browse files
Americaskeithamus
authored andcommitted
feat: ignore pre and post sort logic if script starts with "-" (#49)
1 parent 0faf8e4 commit ccbc536

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ function sortPackageJson(packageJson) {
8989
*/
9090
function compareScriptKeys(a, b) {
9191
if (a === b) return 0;
92-
var aScript = a.replace(/^(pre|post)(.)/, '$2');
93-
var bScript = b.replace(/^(pre|post)(.)/, '$2');
92+
var aScript = a.replace(/^(pre|post)([^-])/, '$2');
93+
var bScript = b.replace(/^(pre|post)([^-])/, '$2');
9494
if (aScript === bScript) {
9595
// pre* is always smaller; post* is always bigger
9696
// Covers: pre* vs. *; pre* vs. post*; * vs. post*

test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@ require('fs').readFile('./package.json', 'utf8', function (error, contents) {
2727
start: 'node server.js',
2828
posttest: 'abc',
2929
pretest: 'xyz',
30+
'pre-fetch-info': 'foo'
3031
}
3132
}).scripts), [
3233
'postinstall',
3334
'multiply',
35+
'pre-fetch-info',
3436
'start',
3537
'pretest',
3638
'test',

0 commit comments

Comments
 (0)