Browse Source

Accumulate process messages

production
Pradeep Bhaskaran 4 years ago
parent
commit
63f066d2a6
1 changed files with 15 additions and 10 deletions
  1. 15
    10
      index.js

+ 15
- 10
index.js View File

if(existsSync(clonable)) { if(existsSync(clonable)) {
console.log('pulling ' + clonable) console.log('pulling ' + clonable)
nodeShellExec('git', ['pull'], { nodeShellExec('git', ['pull'], {
inherit : true, shell: true
, cwd : clonable
, env: process.env
// inherit : true, shell: true
// ,
cwd : clonable
// , env: process.env
, title : `git pull ${clonable}` , title : `git pull ${clonable}`
}).catch((e)=>{ console.error(e) }) }).catch((e)=>{ console.error(e) })
} }
console.log('cloning ' + clonable) console.log('cloning ' + clonable)
nodeShellExec('git', ['clone', '//172.16.0.27/repos/' + clonable + '.git'], nodeShellExec('git', ['clone', '//172.16.0.27/repos/' + clonable + '.git'],
{ {
inherit : true, shell: true
, cwd : clonable
, env: process.env
, title : `git pull ${clonable}`
// inherit : true, shell: true
// ,
cwd : clonable
// , env: process.env
, title : `git clone ${'//172.16.0.27/repos/' + clonable + '.git'}`
}).catch((e)=>{ console.error(e) }) }).catch((e)=>{ console.error(e) })
} }
}) })
// }; // };
// nodeShellExec('git', ['init'], { inherit : true}); // nodeShellExec('git', ['init'], { inherit : true});
if(0){ if(0){
// PB : TODO -- Special google chrome profile for tests etc.
nodeShellExec('pwd', { inherit : true}); nodeShellExec('pwd', { inherit : true});
//$ "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 1" http://localhost:4200/tests/index.html?grep=loopback //$ "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --profile-directory="Profile 1" http://localhost:4200/tests/index.html?grep=loopback
nodeShellExec("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe", [ nodeShellExec("C:/Program Files (x86)/Google/Chrome/Application/chrome.exe", [
const child = spawn(...arguments); const child = spawn(...arguments);


return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){

var messages = []; // PB : TODO -- Explore stream for Task level aggregation to prevent interleaved messages from multiple tasks...
// use child.stdout.setEncoding('utf8'); if you want text chunks // use child.stdout.setEncoding('utf8'); if you want text chunks
child.stdout.setEncoding('utf8'); child.stdout.setEncoding('utf8');
child.stdout.on('data', (chunk) => console.log(chunk));
child.on('error', (chunk) => console.error(chunk));
child.stdout.on('data', (chunk) => { messages.push(chunk); /*console.log(chunk)*/});
child.on('error', (chunk) => { messages.push(chunk); /*console.error(chunk)*/ });
child.stderr.pipe(process.stderr); child.stderr.pipe(process.stderr);


child.on('close', (code) => { child.on('close', (code) => {
console.log(` ${args[2].title} exited with code ${code}`) console.log(` ${args[2].title} exited with code ${code}`)
console.log(messages)
if(code !== 0 ) return reject(code) if(code !== 0 ) return reject(code)
resolve(true) resolve(true)
}); });

Loading…
Cancel
Save