Skip to content

Commit

Permalink
feat: make logs in "Deploy" pane prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j committed Oct 8, 2021
1 parent f86a2eb commit 74f9d6c
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions packages/cli-plugin-deploy-pulumi/commands/watch.js
Expand Up @@ -40,7 +40,7 @@ module.exports = async (inputs, context) => {
}

inputs.build = inputs.build !== false;
inputs.deploy = Boolean(projectApplication && inputs.deploy !== false);
inputs.deploy = projectApplication && inputs.deploy !== false;

if (inputs.deploy && !inputs.env) {
throw new Error(`Please specify environment, for example "dev".`);
Expand Down Expand Up @@ -218,10 +218,31 @@ module.exports = async (inputs, context) => {
});

watchCloudInfrastructure.stdout.on("data", data => {
output.log({
type: "deploy",
message: data.toString()
});
const line = data.toString();

try {
const [, , name, message] = line
.match(/(.*)\[(.*)\] (.*)/)
.map(item => item.trim());

if (name) {
const coloredName = chalk.hex(getRandomColorForString(name)).bold(name);
output.log({
type: "deploy",
message: `${coloredName}: ${message}`
});
} else {
output.log({
type: "deploy",
message
});
}
} catch (e) {
output.log({
type: "deploy",
message: line
});
}
});

watchCloudInfrastructure.stderr.on("data", data => {
Expand Down

0 comments on commit 74f9d6c

Please sign in to comment.