Skip to content

Commit 126f6da

Browse files
committed
Fix fs.stat error for not existing binary or local component locations
1 parent 8927005 commit 126f6da

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/odo.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,18 +382,23 @@ export class OdoImpl implements Odo {
382382
}
383383
const componentObject = data.map(value => ({ name: value.metadata.name, source: value.spec.source }));
384384

385-
return componentObject.map<OpenShiftObject>((value) =>
386-
{
387-
let compSource: string = '';
385+
return componentObject.map<OpenShiftObject>((value) => {
386+
let compSource: string = '';
387+
try {
388388
if (value.source.startsWith('https://')) {
389389
compSource = 'git';
390390
} else if (statSync(Uri.parse(value.source).fsPath).isFile()) {
391391
compSource = 'binary';
392392
} else if (statSync(Uri.parse(value.source).fsPath).isDirectory()) {
393393
compSource = 'folder';
394394
}
395-
return new OpenShiftObjectImpl(application, value.name, ContextType.COMPONENT, this, TreeItemCollapsibleState.Collapsed, compSource);
396-
});
395+
} catch (ignore) {
396+
// treat component as local in case of error when calling statSync
397+
// for not existing file or folder
398+
compSource = 'folder';
399+
}
400+
return new OpenShiftObjectImpl(application, value.name, ContextType.COMPONENT, this, TreeItemCollapsibleState.Collapsed, compSource);
401+
});
397402
}
398403

399404
public async getComponentTypes(): Promise<string[]> {

0 commit comments

Comments
 (0)