var express = require('express');
var cproc = require('child_process');
var execSync = cproc.execSync;


var app = express();
var admin = express(); // the sub app

admin.get('/get_node_command/:name', function (req, res) {
  console.log(req.params.name)
 res.setHeader("Content-Type","application/json");
	var str = execSync(`node ./get_project_config.js  -name ${req.params.name} -attr config_file/command/gitPathHead`)
var items = String(str).replace(/\n/g,"").split("|"); 
 var config_file = items[0].replace(/\^/g," ");
console.log(items)
console.log(items);
var command  = items[1].replace(/\^/g," ");
var gitGroup = items[2].replace(/\^/g," ");

 res.send({configPath:config_file,buildCmd:command,gitGroup:gitGroup});
});
app.use('/config_server', admin);
console.log("http://192.168.4.3:10088/config_server/get_node_command") 
app.listen(10088)
