Skip to content

Commit

Permalink
ensure consistent sort order when pattern matches >1 files
Browse files Browse the repository at this point in the history
  • Loading branch information
chris48s committed Aug 19, 2024
1 parent d2aa505 commit 195bc17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/cli.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1006,13 +1006,6 @@ describe("CLI", function () {
}).then(() => {
const expected = {
results: [
{
code: 0,
errors: [],
fileLocation: "./testfiles/files/valid.json",
schemaLocation: "./testfiles/schemas/schema.json",
valid: true,
},
{
code: 99,
errors: [
Expand All @@ -1037,6 +1030,13 @@ describe("CLI", function () {
schemaLocation: "./testfiles/schemas/schema.json",
valid: null,
},
{
code: 0,
errors: [],
fileLocation: "./testfiles/files/valid.json",
schemaLocation: "./testfiles/schemas/schema.json",
valid: true,
},
],
};
assert.deepStrictEqual(JSON.parse(logger.stdout[0]), expected);
Expand Down
4 changes: 3 additions & 1 deletion src/glob.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import logger from "./logger.js";

async function getFiles(pattern) {
try {
return await glob(pattern, { dot: true, dotRelative: true });
let matches = await glob(pattern, { dot: true, dotRelative: true });
matches.sort((a, b) => a.localeCompare(b));
return matches;
} catch (e) {
logger.error(e.message);
return [];
Expand Down

0 comments on commit 195bc17

Please sign in to comment.