Wednesday 7 February 2018

How do I export the PATH env in Node.js using execSync?

Hey all.I've run into some trouble with a script I am writing to automate multiple installs, I've resorted to using execSync to execute my commands and everything works exactly like I expect it to until the end. I have to export this path "export PATH=~/.composer/vendor/bin:$PATH" although when executed it doesn't seem to run at all. Any help would be greatly appreciated! If I've not been clear enough just let me know.Code below:const commands = { laravelInstallCommands: [ 'composer global require "laravel/installer=~1.1"', "export PATH=~/.composer/vendor/bin:$PATH" ] }; const laravelInstall = () => { const laravelCommands = commands["laravelInstallCommands"]; for (let keys in laravelCommands) { const data = laravelCommands[keys]; execSync(data, { detached: true, stdio: "inherit", shell: true }); } }; laravelInstall(); Any help would be greatly appreciated. Cheers.

Submitted February 07, 2018 at 12:39PM by Reeferchief

No comments:

Post a Comment