MCPcopy Create free account
hub / github.com/Snapchat/Valdi / computeImportPath

Function computeImportPath

npm_modules/cli/src/commands/preview.ts:60–66  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

58 * → widgets/src/components/button/Checkbox
59 */
60function 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
68async function valdiPreview(argv: ArgumentsResolver<CommandParameters>) {
69 const bazel = new BazelClient();

Callers 1

valdiPreviewFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected