mirror of
https://github.com/Matysh/houseplan-card
synced 2026-10-06 06:38:57 +00:00
v1.60.0-beta.1: unify background editing and device deletion
This commit is contained in:
@@ -1,8 +1,25 @@
|
||||
// tsc keeps extensionless relative imports; Node ESM requires explicit ".js".
|
||||
// Walk the complete output tree: feature modules may import siblings from a
|
||||
// nested directory, and a root-only pass leaves those suites unable to start.
|
||||
import { readdirSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
for (const f of readdirSync('test-build')) {
|
||||
if (!f.endsWith('.js')) continue;
|
||||
const p = `test-build/${f}`;
|
||||
const s = readFileSync(p, 'utf8').replace(/from\s+'(\.\/[\w-]+)'/g, "from '$1.js'");
|
||||
writeFileSync(p, s);
|
||||
}
|
||||
import { extname, join } from 'node:path';
|
||||
|
||||
const patchImports = (dir) => {
|
||||
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
||||
const path = join(dir, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
patchImports(path);
|
||||
continue;
|
||||
}
|
||||
if (!entry.name.endsWith('.js')) continue;
|
||||
const source = readFileSync(path, 'utf8').replace(
|
||||
/(from\s+['"]|import\s*\(\s*['"])(\.\.?\/[^'"]+)(['"])/g,
|
||||
(match, prefix, specifier, suffix) => (
|
||||
extname(specifier) ? match : `${prefix}${specifier}.js${suffix}`
|
||||
),
|
||||
);
|
||||
writeFileSync(path, source);
|
||||
}
|
||||
};
|
||||
|
||||
patchImports('test-build');
|
||||
|
||||
Reference in New Issue
Block a user