From afd021fffa674199a21f5b7c98103534f03080e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Thu, 26 Aug 2021 23:28:52 +0200 Subject: [PATCH] fix a bug --- demos/vite.config.ts | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/demos/vite.config.ts b/demos/vite.config.ts index 01cc7b35..40ade7ad 100644 --- a/demos/vite.config.ts +++ b/demos/vite.config.ts @@ -33,6 +33,8 @@ export default defineConfig({ 'y-websocket', 'y-indexeddb', 'y-webrtc', + 'lowlight', + 'lowlight/lib/core', ], }, @@ -124,19 +126,33 @@ export default defineConfig({ content: fs.readFileSync(`${path}/${name}`, 'utf8'), } }) + .sort((a, b) => { + const depthA = a.name.split('/').length + const depthB = b.name.split('/').length - const sortedFiles = files.sort(item => { - if ( - item.name.split('/').length === 0 - && basename(item.name).startsWith('index.') - ) { - return -1 - } + if (depthA > depthB) { + return 1 + } - return 1 - }) + if (depthA < depthB) { + return -1 + } - return `export default ${JSON.stringify(sortedFiles)}` + const aIsIndex = basename(a.name).includes('index.') + const bIsIndex = basename(b.name).includes('index.') + + if (aIsIndex) { + return -1 + } + + if (bIsIndex) { + return 1 + } + + return 0 + }) + + return `export default ${JSON.stringify(files)}` } }, },