mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 02:43:48 +02:00
Fix incorrectly fixed .js imports
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
// .js extensions are technically required in compliant ECMAScript, and Webpack needs them, so we add them here.
|
||||
|
||||
const walkDir = (dir: string) => {
|
||||
const files: string[] = [];
|
||||
const items = fs.readdirSync(dir);
|
||||
|
||||
for (const item of items) {
|
||||
const fullPath = path.join(dir, item);
|
||||
const stat = fs.statSync(fullPath);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
files.push(...walkDir(fullPath));
|
||||
} else if (item.endsWith('.js')) {
|
||||
files.push(fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
};
|
||||
|
||||
const fixFile = (filePath: string) => {
|
||||
const content = fs.readFileSync(filePath, 'utf8');
|
||||
const fixed = content.replace(
|
||||
/(\s+from\s+['"])([^'"]*)(['"])/g,
|
||||
'$1$2.js$3',
|
||||
);
|
||||
|
||||
if (content !== fixed) {
|
||||
fs.writeFileSync(filePath, fixed);
|
||||
}
|
||||
};
|
||||
|
||||
const jsFiles = walkDir('dist');
|
||||
jsFiles.forEach(fixFile);
|
||||
@@ -1,5 +1,5 @@
|
||||
import ts from 'typescript';
|
||||
import * as fs from 'node:fs';
|
||||
import * as fs from 'fs';
|
||||
|
||||
const checkDocblocks = (filePath: string) => {
|
||||
const program = ts.createProgram([filePath], {});
|
||||
|
||||
Reference in New Issue
Block a user