-
Notifications
You must be signed in to change notification settings - Fork 0
/
readfiles_script.js
51 lines (43 loc) · 1.62 KB
/
readfiles_script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const vscode = require('vscode');
const fs = require('fs');
const path = require('path');
const { exec } = require('child_process');
/**
* @param {vscode.ExtensionContext} context
*/
function activate(context) {
console.log('Congratulations, your extension "auto-conda-runner" is now active!');
// Register a command to run the conda command
let disposable = vscode.commands.registerCommand('extension.runCondaCommand', function () {
const folders = vscode.workspace.workspaceFolders;
if (folders) {
const folderPath = folders[0].uri.fsPath;
// Read folder contents
fs.readdir(folderPath, (err, files) => {
if (err) {
vscode.window.showErrorMessage('Failed to read folder contents');
return;
}
// Example: Print the files
console.log('Files in the folder:', files);
// Run a Conda command
const condaCommand = 'conda list'; // Replace with your conda command
exec(condaCommand, (err, stdout, stderr) => {
if (err) {
vscode.window.showErrorMessage(`Conda command failed: ${stderr}`);
return;
}
vscode.window.showInformationMessage(`Conda command output: ${stdout}`);
});
});
} else {
vscode.window.showErrorMessage('No folder is open');
}
});
context.subscriptions.push(disposable);
}
function deactivate() {}
module.exports = {
activate,
deactivate
};