diff --git a/e2e/commands/status.e2e.2.ts b/e2e/commands/status.e2e.2.ts index 41914bb3f3fe..765f0a24ab17 100644 --- a/e2e/commands/status.e2e.2.ts +++ b/e2e/commands/status.e2e.2.ts @@ -382,7 +382,7 @@ describe('bit status command', function () { describe('running bit diff', () => { it('should throw an exception ComponentNotFoundInPath', () => { const diffFunc = () => helper.command.diff('bar/foo'); - const error = new ComponentNotFoundInPath(path.join(helper.scopes.localPath, 'bar')); + const error = new ComponentNotFoundInPath('bar'); helper.general.expectToThrow(diffFunc, error); }); }); diff --git a/src/consumer/component/consumer-component.ts b/src/consumer/component/consumer-component.ts index 070c669ae1f9..ecaa3fea30ac 100644 --- a/src/consumer/component/consumer-component.ts +++ b/src/consumer/component/consumer-component.ts @@ -521,7 +521,7 @@ export default class Component { } const deprecated = componentFromModel ? componentFromModel.deprecated : false; const compDirAbs = path.join(consumer.getPath(), componentMap.getComponentDir()); - if (!fs.existsSync(compDirAbs)) throw new ComponentNotFoundInPath(compDirAbs); + if (!fs.existsSync(compDirAbs)) throw new ComponentNotFoundInPath(componentMap.getComponentDir()); // Load the base entry from the root dir in map file in case it was imported using -path // Or created using bit create so we don't want all the path but only the relative one diff --git a/src/consumer/component/exceptions/component-not-found-in-path.ts b/src/consumer/component/exceptions/component-not-found-in-path.ts index 7e46742fc698..b33e7b57ea81 100644 --- a/src/consumer/component/exceptions/component-not-found-in-path.ts +++ b/src/consumer/component/exceptions/component-not-found-in-path.ts @@ -6,7 +6,12 @@ export default class ComponentNotFoundInPath extends BitError { code: number; constructor(path: string, cause?: Error) { - super(`error: component in path "${chalk.bold(path)}" was not found`); + super(`error: component in path "${chalk.bold( + path + )}" was not found, the following options are available depending on the situation: +1. if the component directory was deleted by mistake, you can restore it by running "bit checkout reset ". +2. if the component-dir was renamed, you can use "bit move" to move it to the new location. +3. if the component directory was deleted deliberately, you can remove it from the workspace by running "bit remove ".`); this.code = 127; this.path = path; if (cause) this.cause = cause;