Skip to content

Commit

Permalink
fix(StackResourceWatcher): clear number of lines written instead of e…
Browse files Browse the repository at this point in the history
…ntire terminal
  • Loading branch information
jedwards1211 committed Apr 1, 2022
1 parent 0540710 commit a4c71f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/StackResourceWatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class StackResourceWatcher {
_StackNames: Array<string> = []
_options: Options
_intervalID: ?IntervalID = null
_linesWritten: number = 0

constructor(options: Options) {
this._options = options
Expand Down Expand Up @@ -78,22 +79,26 @@ export default class StackResourceWatcher {
)
)
if (clearScreen !== false) {
process.stderr.write(ansi.clearScreen)
process.stderr.write(ansi.cursorTo(0, 0))
process.stderr.write(ansi.eraseLines(this._linesWritten + 1))
}
this._linesWritten = 0
for (let i = 0; i < StackNames.length; i++) {
const { resources, error } = stackResources[i]
process.stderr.write(
chalk`${i > 0 ? '\n' : ''}{bold ${StackNames[i]}}:\n\n`
)
this._linesWritten += i > 0 ? 3 : 2
if (error) {
process.stderr.write(
chalk.red(`Failed to get stack resources: ${error.message}`)
chalk.red(`Failed to get stack resources: ${error.message}\n\n`)
)
this._linesWritten += 1 + error.message.split(/\n/gm).length
}
if (!Array.isArray(resources)) continue
printStackResources({ resources })
this._linesWritten += resources.length + 1
}
process.stderr.write(new Date().toString() + '\n')
this._linesWritten++
}
}
2 changes: 1 addition & 1 deletion src/securityGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export async function upsertSecurityGroup({
})
if (!securityGroupId) {
// eslint-disable-next-line no-console
console.log(`creating ${securityGroupName} security group...`)
console.error(`creating ${securityGroupName} security group...`)
securityGroupId = (await ec2
.createSecurityGroup({
Description: securityGroupDescription || '',
Expand Down

0 comments on commit a4c71f8

Please sign in to comment.