diff --git a/scripts/stdlib/utils.js b/scripts/stdlib/utils.js index 152a627d58a..42e4132e5d9 100644 --- a/scripts/stdlib/utils.js +++ b/scripts/stdlib/utils.js @@ -17,21 +17,16 @@ module.exports.TARGET_REFLECT_MODULE_DIR = TARGET_ROOT_PATH + '/kotlin-reflect'; module.exports.exists = async function exists(path) { try { await access(path); - return true; } catch (e) { - // + return false; } - return false; + return true; }; module.exports.writeRedirects = async function writeRedirects(name, urls) { const content = urls - .map(([from, to]) => ({ from: '/' + from, to: '/' + to.replace(/\/index\.html$/, '/') })) - .sort(function(a, b) { - if (a.from < b.from) return -1; - if (a.from > b.from) return 1; - return 0; - }); + .map(([from, to]) => ({ from: '/' + to.replace(/\/index\.html$/, '/'), to: '/' + from })) + .sort((a, b) => a.from.localeCompare(b.from)); console.log(`write ${urls.length} redirects...`); await writeFile(name, YAML.stringify(content), 'utf8');