Complete the code to import the execFile function from the child_process module.
const { [1] } = require('child_process');The execFile function is imported from the child_process module to run executables directly.
Complete the code to run the executable 'ls' with execFile.
execFile('[1]', (error, stdout, stderr) => { if (error) { console.error(error); return; } console.log(stdout); });
The executable to list directory contents on Unix systems is ls.
Fix the error in the callback parameter to correctly handle the error.
execFile('ls', ([1], stdout, stderr) => { if (error) { console.error(error); return; } console.log(stdout); });
The callback parameter name must match the variable used inside the function. Here, error is used, so the parameter must be named error.
Fill both blanks to run 'node' with arguments to execute a script file 'app.js'.
execFile('[1]', ['[2]'], (error, stdout, stderr) => { if (error) { console.error(error); return; } console.log(stdout); });
The node executable runs JavaScript files, and here it runs the script app.js.
Fill all three blanks to run 'git' with arguments to show the current branch name.
execFile('[1]', ['[2]', '[3]'], (error, stdout, stderr) => { if (error) { console.error(error); return; } console.log(`Current branch: ${stdout.trim()}`); });
The command git branch --show-current shows the current branch name.