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}`);
});
}
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}`); }); }