-
Notifications
You must be signed in to change notification settings - Fork 3
/
export.js
27 lines (25 loc) · 874 Bytes
/
export.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const path = require('path');
const fs = require('fs');
function readdirFilesRecursiveSync(dir, output) {
output = output || [];
fs.readdirSync(dir).forEach(file => {
let fullPath = path.join(dir, file);
if (fs.lstatSync(fullPath).isDirectory()) {
readdirFilesRecursiveSync(fullPath, output);
} else {
output.push(fullPath);
}
});
return output;
}
fs.writeFileSync(
path.join('src', 'main.js'),
"import './init';\n" +
"export { globalRequiredMarker, globalOptionalMarker } from './stores/markers';\n" +
"export { generateId } from './services/html';\n" +
readdirFilesRecursiveSync(path.join('src', 'components'))
.filter((entry) => !entry.endsWith('.preview.svelte'))
.map((entry) => './' + entry.substring('src/'.length))
.map((entry) => 'export { default as ' + entry.match(/([^/]+).svelte/)[1] + ' } from "' + entry + '";')
.join('\n')
);