fix: path issue on Windows (#5725)
This commit is contained in:
2 files changed
+32
-31
No files matched your search
@@ -1,31 +1,32 @@
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import path, { join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import * as glob from 'glob';
|
||||
|
||||
// purpose: bundle all json files into one json file in onboarding folder
|
||||
const __dirname = new URL('.', import.meta.url).pathname;
|
||||
const __dirname = join(fileURLToPath(import.meta.url), '..');
|
||||
|
||||
const jsonFiles = glob.sync('./*.json', {
|
||||
cwd: path.resolve(__dirname, 'onboarding'),
|
||||
cwd: path.join(__dirname, 'onboarding'),
|
||||
});
|
||||
|
||||
const imports = jsonFiles
|
||||
.map((fileName, index) => {
|
||||
return `import json_${index} from './onboarding/${fileName}';`;
|
||||
})
|
||||
.map(
|
||||
(fileName, index) => `import json_${index} from './onboarding/${fileName}';`
|
||||
)
|
||||
.join('\n');
|
||||
|
||||
const exports = `export const onboarding = {
|
||||
${jsonFiles
|
||||
.map((fileName, index) => {
|
||||
return `'${fileName}': json_${index}`;
|
||||
})
|
||||
.join(',\n')}
|
||||
${jsonFiles
|
||||
.map((fileName, index) => {
|
||||
return ` '${fileName}': json_${index}`;
|
||||
})
|
||||
.join(',\n')}
|
||||
}`;
|
||||
|
||||
const template = `/* eslint-disable simple-import-sort/imports */
|
||||
// Auto generated, do not edit manually
|
||||
${imports}\n\n${exports}`;
|
||||
|
||||
fs.writeFileSync(path.resolve(__dirname, 'templates.gen.ts'), template);
|
||||
fs.writeFileSync(path.join(__dirname, 'templates.gen.ts'), template);
|
||||
Reference in new issue
Block a user