const conn = new Client();
conn.on( 'ready', () => {
const command = `rm -rf /opt/git/${ name }.git`;
+ console.log(command);
+ console.log([...command].join( ' && ' ));
conn.exec( command, ( err, stream ) => {
if (err) {
conn.end();
} ).connect( sshConfig );
}, cloneRepo:async ( req, res, next ) => {
const { repoName, deployPath, user } = req.body;
- console.log(repoName, deployPath, user);
if (!repoName || !deployPath || !user) {
return res.status( 400 ).json( { error:'Repository name, deployment path, and user are required' } );
}
const conn = new Client();
conn.on( 'ready', () => {
- console.log('ready');
const commands = [`mkdir -p ${ deployPath }`, `chown ${ user }:${ user } ${ deployPath }`, `cd ${ deployPath } && git clone ${ user }@localhost:/opt/git/${ repoName }.git .`,];
- console.log(commands);
- console.log([...commands].join( ' && ' ));
conn.exec( commands.join( ' && ' ), ( err, stream ) => {
if (err) {
conn.end();