mirror of
https://github.com/microsoft/vscode-extension-samples.git
synced 2026-04-27 16:55:44 +08:00
Merge pull request #96 from sana-ajani/master
add consistent Promise structure
This commit is contained in:
@ -23,20 +23,19 @@ export class DepNodeProvider implements vscode.TreeDataProvider<Dependency> {
|
||||
vscode.window.showInformationMessage('No dependency in empty workspace');
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
return new Promise(resolve => {
|
||||
if (element) {
|
||||
resolve(this.getDepsInPackageJson(path.join(this.workspaceRoot, 'node_modules', element.label, 'package.json')));
|
||||
|
||||
if (element) {
|
||||
return Promise.resolve(this.getDepsInPackageJson(path.join(this.workspaceRoot, 'node_modules', element.label, 'package.json')));
|
||||
} else {
|
||||
const packageJsonPath = path.join(this.workspaceRoot, 'package.json');
|
||||
if (this.pathExists(packageJsonPath)) {
|
||||
return Promise.resolve(this.getDepsInPackageJson(packageJsonPath));
|
||||
} else {
|
||||
const packageJsonPath = path.join(this.workspaceRoot, 'package.json');
|
||||
if (this.pathExists(packageJsonPath)) {
|
||||
resolve(this.getDepsInPackageJson(packageJsonPath));
|
||||
} else {
|
||||
vscode.window.showInformationMessage('Workspace has no package.json');
|
||||
resolve([]);
|
||||
}
|
||||
vscode.window.showInformationMessage('Workspace has no package.json');
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,4 +102,4 @@ class Dependency extends vscode.TreeItem {
|
||||
|
||||
contextValue = 'dependency';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user