I’m stuck on Stage #ip1
I’ve tried debugging but the program thinks my debugging messages are the program output.
I think the problem is either Im not passing the correct path, or it is not finding the program. Which is weird because I used the same code to create the type builtin and that one works fine.
Here is my code
function promptUser() {
rl.question("$ ", (answer) => {
const param = answer.split(" ");
const paths = (process.env.PATH || "").split(":");
let found = false;
.
.
.
// process.stdout.write(`Debugging paths: ${paths}\n`);
for (const p of paths) {
const fullPath = path.join(p, param[0]);
//process.stdout.write(`Debugging fullpath: ${fullPath}\n`);
if (require("fs").existsSync(fullPath)) {
const command = `${param.join(" ")}`;
process.stdout.write(`Executing command: ${command}\n`);
exec(command, (error: { message: any; }, stdout: any, stderr: any) => {
if (error) {
rl.write(`error: ${error.message}\n`);
return;
}
if (stderr) {
rl.write(`stderr: ${stderr}\n`);
return;
}
rl.write(`result: ${stdout}\n`);
});
found = true;
break;
}
}
if(!found) {
rl.write(`${param[0]}: command not found\n`);
}
Here are my logs:
remote: [tester::#IP1] Running tests for Stage #IP1 (Run a program)
remote: [tester::#IP1] [setup] export PATH=/tmp/baz:$PATH
remote: [tester::#IP1] [setup] Available executables:
remote: [tester::#IP1] [setup] - custom_exe_6316
remote: [tester::#IP1] Running ./your_program.sh
remote: [your-program] $ custom_exe_6316 Maria
remote: [tester::#IP1] Output does not match expected value.
remote: [tester::#IP1] Expected: "$ custom_exe_6316 Maria"
remote: [tester::#IP1] Received: ""
remote: [your-program] $ result: Program was passed 2 args (including program name).result:: command not found
remote: [your-program] Debugging fullpath: /usr/local/bin/result:
remote: [your-program] $ result: Program was passed 2 args (including program name).result:: command not found
remote: [your-program] Debugging fullpath: /tmp/baz/result:
remote: [your-program] Debugging fullpath: /usr/local/sbin/result:
remote: [your-program] Debugging fullpath: /usr/local/bin/result:
remote: [your-program] Debugging fullpath: /usr/sbin/result:
remote: [your-program] Debugging fullpath: /usr/bin/result:
remote: [your-program] Debugging fullpath: /sbin/result:
remote: [your-program] Debugging fullpath: /bin/result:
remote: [your-program] $ result: Program was passed 2 args (including program name).result:: command not found
Entire repo can be found here: