Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit ae10d32

Browse files
authored
Merge pull request #5 from nickrallison/dev
Dev
2 parents 94c092e + e847a72 commit ae10d32

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

main.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,25 @@ export default class PythonScripterPlugin extends Plugin {
6464
return;
6565
}
6666
if (stats.isFile()) {
67-
exec(`python ${filePath} ${basePath}`, {cwd: this.pythonDirectory}, (error: any, stdout: any, stderr: any) => {
67+
var local_current_file_path = this.app.workspace.activeEditor?.file?.path;
68+
if (local_current_file_path === undefined) {
69+
local_current_file_path = "";
70+
}
71+
exec(`python ${filePath} ${basePath} \"${local_current_file_path}\"`, {cwd: this.pythonDirectory}, (error: any, stdout: any, stderr: any) => {
6872
if (error) {
6973
new Notice(`Error executing script ${filePath}: ${error}`);
7074
return;
7175
}
72-
7376
new Notice(`Script ` + fileName + ` output:\n${stdout}`);
7477
});
75-
} else if (stats.isDirectory()) {
78+
} else if (stats.isDirectory()) {
7679
var dir = path.join(filePath);
7780
var executable = path.join(".", filePath, "src", "main.py");
78-
exec(`python ${executable} ${basePath}`, {cwd: dir}, (error: any, stdout: any, stderr: any) => {
81+
var local_current_file_path = this.app.workspace.activeEditor?.file?.path;
82+
if (local_current_file_path === undefined) {
83+
local_current_file_path = "";
84+
}
85+
exec(`python ${path.join(filePath, "src", "main.py")} ${basePath} \"${local_current_file_path}\"`, {cwd: dir}, (error: any, stdout: any, stderr: any) => {
7986
if (error) {
8087
new Notice(`Error executing folder program: ${error}`);
8188
return;

0 commit comments

Comments
 (0)