diff --git a/packages/cli/src/helpers/path.ts b/packages/cli/src/helpers/path.ts index b943d00..356e19a 100644 --- a/packages/cli/src/helpers/path.ts +++ b/packages/cli/src/helpers/path.ts @@ -41,6 +41,21 @@ export async function getDirComponentInstalledFiles { + const componentDirRoot = path.join(process.cwd(), config.paths.components) + if (!existsSync(componentDirRoot)) return false + + if (component.type === 'file') { + const dir = await readdir(componentDirRoot) + return dir.includes(component.name) + } else { + const componentDir = path.join(componentDirRoot, component.name) + if (!existsSync(componentDir)) return false + const dir = await readdir(componentDir) + return component.files.filter((filename) => !dir.includes(filename)).length === 0 + } +} + export async function changeExtension(_path: string, extension: string): Promise { return path.join(path.dirname(_path), path.basename(_path, path.extname(_path)) + extension) }