fix a bug

This commit is contained in:
Philipp Kühn
2021-08-26 23:28:52 +02:00
parent 8670891ae8
commit afd021fffa

View File

@@ -33,6 +33,8 @@ export default defineConfig({
'y-websocket', 'y-websocket',
'y-indexeddb', 'y-indexeddb',
'y-webrtc', 'y-webrtc',
'lowlight',
'lowlight/lib/core',
], ],
}, },
@@ -124,19 +126,33 @@ export default defineConfig({
content: fs.readFileSync(`${path}/${name}`, 'utf8'), 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 (depthA > depthB) {
if ( return 1
item.name.split('/').length === 0 }
&& basename(item.name).startsWith('index.')
) { if (depthA < depthB) {
return -1 return -1
} }
const aIsIndex = basename(a.name).includes('index.')
const bIsIndex = basename(b.name).includes('index.')
if (aIsIndex) {
return -1
}
if (bIsIndex) {
return 1 return 1
}
return 0
}) })
return `export default ${JSON.stringify(sortedFiles)}` return `export default ${JSON.stringify(files)}`
} }
}, },
}, },