* Compute the import path from a resolved file path. * E.g. /path/to/valdi_modules/widgets/src/components/button/Checkbox.tsx * → widgets/src/components/button/Checkbox
(filePath: string, moduleDir: string)
| 58 | * → widgets/src/components/button/Checkbox |
| 59 | */ |
| 60 | function computeImportPath(filePath: string, moduleDir: string): string { |
| 61 | const moduleName = path.basename(moduleDir); |
| 62 | const relFromModule = path.relative(moduleDir, filePath); |
| 63 | // Remove .tsx extension |
| 64 | const withoutExt = relFromModule.replace(/\.tsx?$/, ''); |
| 65 | return `${moduleName}/${withoutExt}`; |
| 66 | } |
| 67 | |
| 68 | async function valdiPreview(argv: ArgumentsResolver<CommandParameters>) { |
| 69 | const bazel = new BazelClient(); |