I’ve tried the approaches used in the examples as well but no luck.
Here are my logs:
[tester::#IP1] Running ./your_program.sh
[your-program] $ custom_exe_5725 Emily Maria Maria
[your-program] custom_exe_5725 Emily Maria Maria: not found
[tester::#IP1] ^ Line does not match expected value.
[tester::#IP1] Expected: "Program was passed 4 args (including program name)."
[tester::#IP1] Received: "custom_exe_5725 Emily Maria Maria: not found"
[your-program] $
[tester::#IP1] Assertion failed.
[tester::#IP1] Test failed
No matter what I do it seems the spawn method just doesn’t work, I’m probably making a very silly mistake here somewhere but it’s been a week now and I’m stuck here. Any help is greatly appreciated!!
There is not much to go on at the moment. All we can see is that the return is probably not taken since you emit the output seen in the log at bottom of this function.
Since return is not taken, that makes me question whether spawn might also throw and you just continue the loop. Also spawn supposedly has a callback named option you might also be able to get error information from.
I couldn’t find any callback option unfortunately. I tried to log the errors in the catch block to see if there’s any error thrown by spawn but the only errors were file not found errors which are expected. I had also uncommented the console log at line 2 in the snippet, but that never got logged. After the file not found errors it just goes back to the “not found” log at the end.
[tester::#IP1] Running ./your_program.sh
[your-program] $ custom_exe_3070 Alice David
[tester::#IP1] ^ Line does not match expected value.
[tester::#IP1] Expected: "$ custom_exe_3070 Alice David"
[tester::#IP1] Received: " at emitKeys (node:internal/readline/utils:371:14)"
[your-program] at emitKeys.next (<anonymous>)
[your-program] Error: ENOENT: no such file or directory, access '/usr/local/sbin/custom_exe_3070'
[your-program] at Object.accessSync (node:fs:253:11)
[your-program] at pathCheck (/app/app/main.js:51:10)
[your-program] at Interface.<anonymous> (/app/app/main.js:37:7)
[your-program] at Interface.emit (node:events:519:28)
[your-program] at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)
[your-program] at [_line] [as _line] (node:internal/readline/interface:887:18)
[your-program] at [_ttyWrite] [as _ttyWrite] (node:internal/readline/interface:1274:24)
[your-program] at ReadStream.onkeypress (node:internal/readline/interface:264:20)
[your-program] at ReadStream.emit (node:events:519:28)
[your-program] at emitKeys (node:internal/readline/utils:371:14) {
[your-program] errno: -2,
[your-program] code: 'ENOENT',
[your-program] syscall: 'access',
[your-program] path: '/usr/local/sbin/custom_exe_3070'
[your-program] }
[your-program] Error: ENOENT: no such file or directory, access '/usr/local/bin/custom_exe_3070'
[your-program] at Object.accessSync (node:fs:253:11)
[your-program] at pathCheck (/app/app/main.js:51:10)
[your-program] at Interface.<anonymous> (/app/app/main.js:37:7)
[your-program] at Interface.emit (node:events:519:28)
[your-program] at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)
[your-program] at [_line] [as _line] (node:internal/readline/interface:887:18)
[your-program] at [_ttyWrite] [as _ttyWrite] (node:internal/readline/interface:1274:24)
[your-program] at ReadStream.onkeypress (node:internal/readline/interface:264:20)
[your-program] at ReadStream.emit (node:events:519:28)
[your-program] at emitKeys (node:internal/readline/utils:371:14) {
[your-program] errno: -2,
[your-program] code: 'ENOENT',
[your-program] syscall: 'access',
[your-program] path: '/usr/local/bin/custom_exe_3070'
[your-program] }
[your-program] Error: ENOENT: no such file or directory, access '/usr/sbin/custom_exe_3070'
[your-program] at Object.accessSync (node:fs:253:11)
[your-program] at pathCheck (/app/app/main.js:51:10)
[your-program] at Interface.<anonymous> (/app/app/main.js:37:7)
[your-program] at Interface.emit (node:events:519:28)
[your-program] at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)
[your-program] at [_line] [as _line] (node:internal/readline/interface:887:18)
[your-program] at [_ttyWrite] [as _ttyWrite] (node:internal/readline/interface:1274:24)
[your-program] at ReadStream.onkeypress (node:internal/readline/interface:264:20)
[your-program] at ReadStream.emit (node:events:519:28)
[your-program] at emitKeys (node:internal/readline/utils:371:14) {
[your-program] errno: -2,
[your-program] code: 'ENOENT',
[your-program] syscall: 'access',
[your-program] path: '/usr/sbin/custom_exe_3070'
[your-program] }
[your-program] Error: ENOENT: no such file or directory, access '/usr/bin/custom_exe_3070'
[your-program] at Object.accessSync (node:fs:253:11)
[your-program] at pathCheck (/app/app/main.js:51:10)
[your-program] at Interface.<anonymous> (/app/app/main.js:37:7)
[your-program] at Interface.emit (node:events:519:28)
[your-program] at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)
[your-program] at [_line] [as _line] (node:internal/readline/interface:887:18)
[your-program] at [_ttyWrite] [as _ttyWrite] (node:internal/readline/interface:1274:24)
[your-program] at ReadStream.onkeypress (node:internal/readline/interface:264:20)
[your-program] at ReadStream.emit (node:events:519:28)
[your-program] at emitKeys (node:internal/readline/utils:371:14) {
[your-program] errno: -2,
[your-program] code: 'ENOENT',
[your-program] syscall: 'access',
[your-program] path: '/usr/bin/custom_exe_3070'
[your-program] }
[your-program] Error: ENOENT: no such file or directory, access '/sbin/custom_exe_3070'
[your-program] at Object.accessSync (node:fs:253:11)
[your-program] at pathCheck (/app/app/main.js:51:10)
[your-program] at Interface.<anonymous> (/app/app/main.js:37:7)
[your-program] at Interface.emit (node:events:519:28)
[your-program] at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)
[your-program] at [_line] [as _line] (node:internal/readline/interface:887:18)
[your-program] at [_ttyWrite] [as _ttyWrite] (node:internal/readline/interface:1274:24)
[your-program] at ReadStream.onkeypress (node:internal/readline/interface:264:20)
[your-program] at ReadStream.emit (node:events:519:28)
[your-program] at emitKeys (node:internal/readline/utils:371:14) {
[your-program] errno: -2,
[your-program] code: 'ENOENT',
[your-program] syscall: 'access',
[your-program] path: '/sbin/custom_exe_3070'
[your-program] }
[your-program] Error: ENOENT: no such file or directory, access '/bin/custom_exe_3070'
[your-program] at Object.accessSync (node:fs:253:11)
[your-program] at pathCheck (/app/app/main.js:51:10)
[your-program] at Interface.<anonymous> (/app/app/main.js:37:7)
[your-program] at Interface.emit (node:events:519:28)
[your-program] at [_onLine] [as _onLine] (node:internal/readline/interface:416:12)
[your-program] at [_line] [as _line] (node:internal/readline/interface:887:18)
[your-program] at [_ttyWrite] [as _ttyWrite] (node:internal/readline/interface:1274:24)
[your-program] at ReadStream.onkeypress (node:internal/readline/interface:264:20)
[your-program] at ReadStream.emit (node:events:519:28)
[your-program] at emitKeys (node:internal/readline/utils:371:14) {
[your-program] errno: -2,
[your-program] code: 'ENOENT',
[your-program] syscall: 'access',
[your-program] path: '/bin/custom_exe_3070'
[your-program] }
[your-program] custom_exe_3070 Alice David: not found
[your-program] $
[tester::#IP1] Assertion failed.
[tester::#IP1] Test failed
What’s even more funny is that when I remove the console log from the catch block, I get the output for console.log(execPath, command, cmdArgs);
Solved. I was missing the fact that I have to wait for the custom exe to run, even though I had already tried this using promise earlier. One of the solutions I saw hadn’t used any async logic at all.