Reputation: 2516
I am trying out creating a VS Code Extension and want to get a list of files in the current workspace.
I've created an extension using yo
, following the Hello World documentation.
I am trying to get the list of files in the current workspace with the following code:
let disposable = vscode.commands.registerCommand('extension.removeConsoleLogs', async () => {
// The code you place here will be executed every time your command is executed
const files = await vscode.workspace.findFiles('**.*.*', '**/node_modules/**');
vscode.window.showInformationMessage('number of files',files.length.toString());
files.forEach(file => {
vscode.window.showInformationMessage('Hello VS Code!!!!!');
});
// Display a message box to the user
});
When I open a folder with files in it in the VS Code developer and then run the extension
number of files 0
is output
Can anyone see what I'm doing wrong?
Upvotes: 3
Views: 1790
Reputation: 2483
just fix the include GlobPattern match pattern.
const files = await vscode.workspace.findFiles('**/*.*', '**/node_modules/**');
Upvotes: 4