Last active
August 29, 2015 14:04
-
-
Save alanhoff/98b9874983091f4b4837 to your computer and use it in GitHub Desktop.
Ferramentas com o commander
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var commander = require('commander'); | |
var fs = require('fs'); | |
var path = require('path'); | |
var child = require('child_process'); | |
commander | |
.version('0.0.1') | |
.option('-p, --projeto <nome>', 'Cria um projeto') | |
.option('-d, --deploy', 'Faz o deploy de um projeto') | |
.parse(process.argv); | |
if(commander.projeto){ | |
console.log('Iniciando um novo projeto: %s', commander.projeto); | |
var location = path.join(process.cwd(), commander.projeto); | |
var svn = 'https://local.do.meu/svn'; | |
// Cria uma pasta | |
fs.mkdirSync(location); | |
// Executa o svn dentro da pasta | |
child.exec('svn checkout ' + svn + ' ' + location, function(err){ | |
if(err) | |
throw err; | |
console.log('Terminou!'); | |
}); | |
} | |
if(commander.deploy){ | |
console.log('Fazendo deploy do projeto atual %s', process.cwd()); | |
var servidor = 'deploy@192.192.168.0.180:/pasta/do/deploy'; | |
child.exec('scp ' + process.cwd() + ' ' + servidor, function(err){ | |
if(err) | |
throw err; | |
console.log('Terminou!'); | |
}); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment