Search posts, tags, users, and pages
DoyinSoft Technologies
Software Company
saud chougle
Learner, Software Developer, Freelancer
hi, You can set multiple paths. or conditions according to your needs. I would love to see if you make it more interesting.
chougle saud So I decided to enhance the codes making it possible to type in the desired path upon execution of the script:
you can find the new script below
const { exec } = require("child_process"); const readline = require("readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); var fp = ""; rl.question("Enter a Valid Path to Open: ", function (p) { fp = p; main(); rl.close(); }); function main() { launchVSCodeAt(fp); launchTerminalAt(fp); } function launchVSCodeAt(path) { exec(`cd ${path} && code .`, (err) => { if (err) console.log(`failed to launch VSCode at ${path}`); console.log(`VSCode launched at ${path}`); }); } function launchTerminalAt(path) { exec(`cd ${path} && start cmd`, (error) => { if (error) console.log(`failed to launch Terminal at ${path}`); console.log(`Terminal launched at ${path}`); }); }