Skip to content

Commit c52dd56

Browse files
committed
feat(script-ordering): it should sort lint scripts above other scripts
1 parent 8d8848f commit c52dd56

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/package/scripts/script-comparator.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,13 @@ export default function compareScriptNames(a, b) {
4343
return 1;
4444
}
4545

46+
if (aBase.startsWith('lint:')) {
47+
return -1;
48+
}
49+
50+
if (bBase.startsWith('lint:')) {
51+
return 1;
52+
}
53+
4654
return 0;
4755
}

src/package/scripts/script-comparator.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,9 @@ describe('script name comparator', () => {
4646
expect(compareScriptNames(`prelint:${any.word()}`, `pretest:${any.word()}`)).toEqual(A_BEFORE_B);
4747
expect(compareScriptNames(`pretest:${any.word()}`, `prelint:${any.word()}`)).toEqual(A_AFTER_B);
4848
});
49+
50+
it('should sort undefined scripts below `lint:` scripts', async () => {
51+
expect(compareScriptNames(any.word(), `lint:${any.word()}`)).toEqual(A_AFTER_B);
52+
expect(compareScriptNames(`lint:${any.word()}`, any.word())).toEqual(A_BEFORE_B);
53+
});
4954
});

0 commit comments

Comments
 (0)