mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
Show message when no scripts were found
This commit is contained in:
parent
b42cc7f929
commit
6ed74d7736
|
@ -90,8 +90,15 @@ class NpmScript extends TreeItem {
|
|||
}
|
||||
}
|
||||
|
||||
class NoScripts extends TreeItem {
|
||||
constructor() {
|
||||
super(localize('noScripts', 'No scripts found'), TreeItemCollapsibleState.None);
|
||||
this.contextValue = 'noscripts';
|
||||
}
|
||||
}
|
||||
|
||||
export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
|
||||
private taskTree: Folder[] | PackageJSON[] | null = null;
|
||||
private taskTree: Folder[] | PackageJSON[] | NoScripts[] | null = null;
|
||||
private extensionContext: ExtensionContext;
|
||||
private _onDidChangeTreeData: EventEmitter<TreeItem | null> = new EventEmitter<TreeItem | null>();
|
||||
readonly onDidChangeTreeData: Event<TreeItem | null> = this._onDidChangeTreeData.event;
|
||||
|
@ -263,6 +270,9 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
|
|||
if (element instanceof NpmScript) {
|
||||
return element.package;
|
||||
}
|
||||
if (element instanceof NoScripts) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -271,6 +281,9 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
|
|||
let tasks = await workspace.fetchTasks({ type: 'npm' });
|
||||
if (tasks) {
|
||||
this.taskTree = this.buildTaskTree(tasks);
|
||||
if (this.taskTree.length === 0) {
|
||||
this.taskTree = [new NoScripts()];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (element instanceof Folder) {
|
||||
|
@ -282,6 +295,9 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
|
|||
if (element instanceof NpmScript) {
|
||||
return [];
|
||||
}
|
||||
if (element instanceof NoScripts) {
|
||||
return [];
|
||||
}
|
||||
if (!element) {
|
||||
if (this.taskTree) {
|
||||
return this.taskTree;
|
||||
|
@ -290,7 +306,7 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
|
|||
return [];
|
||||
}
|
||||
|
||||
private buildTaskTree(tasks: Task[]): Folder[] | PackageJSON[] {
|
||||
private buildTaskTree(tasks: Task[]): Folder[] | PackageJSON[] | NoScripts[] {
|
||||
let folders: Map<String, Folder> = new Map();
|
||||
let packages: Map<String, PackageJSON> = new Map();
|
||||
|
||||
|
|
|
@ -245,7 +245,7 @@ async function findAllScripts(buffer: string): Promise<StringMap> {
|
|||
|
||||
let visitor: JSONVisitor = {
|
||||
onError(_error: ParseErrorCode, _offset: number, _length: number) {
|
||||
// TODO inform user about the parse error
|
||||
// TODO: inform user about the parse error
|
||||
},
|
||||
onObjectEnd() {
|
||||
if (inScripts) {
|
||||
|
|
Loading…
Reference in a new issue