print output from create and update testserver commands while command
runs
This commit is contained in:
@@ -5,6 +5,7 @@ const chalk = require('chalk');
|
|||||||
const { AutoComplete, Input, Confirm } = require('enquirer');
|
const { AutoComplete, Input, Confirm } = require('enquirer');
|
||||||
import { defaultMenuSettings, getSettings } from '../../../../globals';
|
import { defaultMenuSettings, getSettings } from '../../../../globals';
|
||||||
import { getRepoBranches } from '../../../../services/github_rest';
|
import { getRepoBranches } from '../../../../services/github_rest';
|
||||||
|
const { spawn } = require('child_process');
|
||||||
|
|
||||||
const getConfirmation = async (branchName: string, stackName: string) => {
|
const getConfirmation = async (branchName: string, stackName: string) => {
|
||||||
const url = stackName.replace('photowall-', '');
|
const url = stackName.replace('photowall-', '');
|
||||||
@@ -115,11 +116,34 @@ module.exports = {
|
|||||||
cmd,
|
cmd,
|
||||||
)}] in folder [${`${config.photowall_repo}/cloudformation/`}]`,
|
)}] in folder [${`${config.photowall_repo}/cloudformation/`}]`,
|
||||||
);
|
);
|
||||||
const output = await system.run(cmd, {
|
const child = spawn(
|
||||||
|
'make',
|
||||||
|
[
|
||||||
|
'create-stack',
|
||||||
|
`STACK_ENVIRONMENT_NAME=${stacksuffix}`,
|
||||||
|
`GITHUB_BRANCH=${branchName}`,
|
||||||
|
],
|
||||||
|
{
|
||||||
cwd: `${config.photowall_repo}/cloudformation/`,
|
cwd: `${config.photowall_repo}/cloudformation/`,
|
||||||
trim: true,
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
child.stdout.setEncoding('utf8');
|
||||||
|
child.stdout.on('data', (data) => {
|
||||||
|
process.stdout.write(data);
|
||||||
|
});
|
||||||
|
child.stderr.on('data', (data) => {
|
||||||
|
process.stderr.write(data);
|
||||||
|
});
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
child.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
resolve(0);
|
||||||
|
} else {
|
||||||
|
reject(new Error(`make exited with code ${code}`));
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
print.fancy(output);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(`e`, e);
|
console.log(`e`, e);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
getSettings,
|
getSettings,
|
||||||
sleep,
|
sleep,
|
||||||
} from '../../../../globals';
|
} from '../../../../globals';
|
||||||
|
const { spawn } = require('child_process');
|
||||||
|
|
||||||
type Stack = {
|
type Stack = {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -126,11 +127,33 @@ module.exports = {
|
|||||||
cmd,
|
cmd,
|
||||||
)}] in folder [${`${config.photowall_repo}/cloudformation/`}]`,
|
)}] in folder [${`${config.photowall_repo}/cloudformation/`}]`,
|
||||||
);
|
);
|
||||||
const output = await system.run(cmd, {
|
const child = spawn(
|
||||||
|
'make',
|
||||||
|
[
|
||||||
|
'update-stack',
|
||||||
|
`STACK_ENVIRONMENT_NAME=${stacksuffix}`,
|
||||||
|
`GITHUB_BRANCH=${branchName}`,
|
||||||
|
],
|
||||||
|
{
|
||||||
cwd: `${config.photowall_repo}/cloudformation/`,
|
cwd: `${config.photowall_repo}/cloudformation/`,
|
||||||
trim: true,
|
},
|
||||||
|
);
|
||||||
|
child.stdout.setEncoding('utf8');
|
||||||
|
child.stdout.on('data', (data) => {
|
||||||
|
process.stdout.write(data);
|
||||||
|
});
|
||||||
|
child.stderr.on('data', (data) => {
|
||||||
|
process.stderr.write(data);
|
||||||
|
});
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
child.on('close', (code) => {
|
||||||
|
if (code === 0) {
|
||||||
|
resolve(0);
|
||||||
|
} else {
|
||||||
|
reject(new Error(`make exited with code ${code}`));
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
print.fancy(output);
|
|
||||||
|
|
||||||
// Check the status
|
// Check the status
|
||||||
const spinner = print.spin(`Waiting for stack to update`);
|
const spinner = print.spin(`Waiting for stack to update`);
|
||||||
|
|||||||
Reference in New Issue
Block a user