Skip to content

Instantly share code, notes, and snippets.

@Streeterxs
Created July 31, 2020 10:51
Show Gist options
  • Save Streeterxs/70b643169901e806b0b51debc2131962 to your computer and use it in GitHub Desktop.
Save Streeterxs/70b643169901e806b0b51debc2131962 to your computer and use it in GitHub Desktop.
const readline = require('readline');
const childProcess = require('child_process');
const readlineInterface = readline.createInterface({
input: process.stdin,
output: process.stdout
});
readlineInterface.question(`Digite o nome do projeto que queira abrir: \n`, (input) => {
const visualCodeProject = childProcess.exec('code .', {cwd: `C:/Users/Afons/Projetos/${input}`});
visualCodeProject.stderr.on('data', (data) => {
console.log('data: ', data);
});
visualCodeProject.stdout.on('error', (error) => {
console.log('error: ', error);
})
visualCodeProject.on('close', () => {
readlineInterface.close();
});
});
readlineInterface.on('close', () => {
setTimeout(() => {
process.exit();
}, 10000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment