Skip to content

Commit

Permalink
file list node better display
Browse files Browse the repository at this point in the history
  • Loading branch information
romgerman committed Apr 20, 2024
1 parent 9767a94 commit 3aab8aa
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/blueprint/nodes/aggregation/file-list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as ts from "typescript";
import * as vscode from "vscode";
import { NodeTypes } from "../../../shared/node-types";
import { BlueprintNode } from "../../blueprint-node";
import { isArrayOfType } from "../../helpers";
Expand All @@ -20,13 +21,28 @@ export class FileListNode extends BlueprintNode {
return tsFileList;
}

async getViewData(): Promise<any> {
async getViewData(): Promise<string[]> {
const tsFileList = (await this.evalInput<ts.SourceFile[]>(0)) || [];

if (isArrayOfType(tsFileList, ts.isSourceFile)) {
return tsFileList.map((x) => x.fileName);
tsFileList.map((sourceFile) => {
const folder = vscode.workspace.getWorkspaceFolder(vscode.Uri.parse("file:///" + sourceFile.fileName));
if (folder) {
return sourceFile.fileName.replace(folder.uri.path.slice(1), "");
} else {
return sourceFile.fileName;
}
});
}

return tsFileList.map((x) => x.getSourceFile().fileName);
return tsFileList.map((x) => {
const sourceFile = x.getSourceFile();
const folder = vscode.workspace.getWorkspaceFolder(vscode.Uri.parse("file:///" + sourceFile.fileName));
if (folder) {
return sourceFile.fileName.replace(folder.uri.path.slice(1), "");
} else {
return sourceFile.fileName;
}
});
}
}

0 comments on commit 3aab8aa

Please sign in to comment.