Merge pull request #22 from AlessandroAnnini/main

feat:  can debug javascript files
pull/21/head^2
biobootloader 2023-04-15 11:10:21 -07:00 zatwierdzone przez GitHub
commit 10fd162ce3
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 42 dodań i 3 usunięć

31
buggy_script.js 100644
Wyświetl plik

@ -0,0 +1,31 @@
const subtractNumbers = (a, b) => {
return a - b;
};
const multiplyNumbers = (a, b) => {
return a * b;
};
const divideNumbers = (a, b) => {
return a / b;
};
function calculate(operation, num1, num2) {
let result = '';
if (operation == 'add') {
result = addNumbers(num1, num2);
} else if (operation == 'subtract') {
result = subtractNumbers(num1, num2);
} else if (operation == 'multiply') {
result = multiplyNumbers(num1, num2);
} else if (operation == 'divide') {
result = divideNumbers(num1, num2);
} else {
console.log('Invalid operation');
}
return res;
}
const [, , operation, num1, num2] = process.argv;
calculate(operation, num1, num2);

Wyświetl plik

@ -23,10 +23,18 @@ with open("prompt.txt") as f:
def run_script(script_name, script_args):
script_args = [str(arg) for arg in script_args]
"""
If script_name.endswith(".py") then run with python
else run with node
"""
subprocess_args = (
[sys.executable, script_name, *script_args]
if script_name.endswith(".py")
else ["node", script_name, *script_args]
)
try:
result = subprocess.check_output(
[sys.executable, script_name, *script_args], stderr=subprocess.STDOUT
)
result = subprocess.check_output(subprocess_args, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
return e.output.decode("utf-8"), e.returncode
return result.decode("utf-8"), 0