You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Let child_process 'cwd' arguments accept a URL #38861
Is your feature request related to a problem? Please describe.
It would be nice if child_process functionality, such as exec, could accept a URL (docs) for the cwd argument. For example the File System writeFileaccepts a URL as its file argument already. So it would be nice for the child_process module to do so as well for path arguments.
This is especially nice with ECMAScript modules since e.g. the old __dirname does not exist anymore, but we are forced to useURL to get a file path to the current file.
Describe the solution you'd like
// Using ESM Module syntax:import{exec}from'child_process/promises';try{const{ stdout }=awaitexec('sysctl -n net.ipv4.ip_local_port_range',{encoding: 'utf8',cwd: newURL('../../',import.meta.url)}// without URL support we would have to have used .pathname here);console.log('successfully executed the child process command');}catch(error){console.error('there was an error:',error.message);}
Activity
child_process: allow `options.cwd` receive a URL
Trott commentedon May 31, 2021
@nodejs/child_process
bl-ue commentedon Jun 2, 2021
What ifURLwere an internet address like this?Edit: see https://github.com/nodejs/node/pull/38862/files#diff-78a58a7046b99f3e5572d1d8a378139226f9963a5d6d7b51551c29f431285c89R72-R76
child_process: allow `options.cwd` receive a URL
child_process: allow `options.cwd` receive a URL
child_process: allow `options.cwd` receive a URL