freeCodeCamp/client/utils/sort-challengefiles.js
Oliver Eyton-Williams 8b601d762e
Some checks failed
Docker -- GHCR - Gitpod / build-and-push-image (gitpod) (push) Has been cancelled
i18n - Build Validation / Validate i18n Builds (20.x) (push) Has been cancelled
CI - Node.js / Lint (20.x) (push) Has been cancelled
i18n - Upload Client UI / Client (push) Has been cancelled
i18n - Upload Curriculum / Learn (push) Has been cancelled
CI - Node.js / Build (20.x) (push) Has been cancelled
CI - Node.js / Test (20.x) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (20.x) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 20.x) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 20.x) (push) Has been cancelled
feat: allow TS to be used in challenges (#56159)
2024-09-19 18:44:09 -04:00

18 lines
657 B
JavaScript

exports.sortChallengeFiles = function sortChallengeFiles(challengeFiles) {
const xs = challengeFiles.slice();
xs.sort((a, b) => {
if (a.history[0] === 'index.html') return -1;
if (b.history[0] === 'index.html') return 1;
if (a.history[0] === 'styles.css') return -1;
if (b.history[0] === 'styles.css') return 1;
if (a.history[0] === 'index.jsx') return -1;
if (b.history[0] === 'index.jsx') return 1;
if (a.history[0] === 'script.js') return -1;
if (b.history[0] === 'script.js') return 1;
if (a.history[0] === 'index.ts') return -1;
if (b.history[0] === 'index.ts') return 1;
return 0;
});
return xs;
};