Skip to content

Commit ed1f5be

Browse files
committed
warn on automatic formatting errors
1 parent e5b1011 commit ed1f5be

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/main.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export default {
111111

112112
// auto-formatting
113113
if (atom.config.get('linter-terraform-syntax.useTerraformFormat') || atom.config.get('linter-terraform-syntax.format.enabled')) {
114-
const fmtArgs = ['fmt', '-list=false'];
114+
const fmtArgs = ['fmt', '-list=false', '-no-color'];
115115

116116
// recursive format if selected
117117
if (atom.config.get('linter-terraform-syntax.recursiveFormat') || atom.config.get('linter-terraform-syntax.format.recursive'))
@@ -122,7 +122,16 @@ export default {
122122
fmtArgs.push(editorFile);
123123

124124
// auto-format the target
125-
helpers.exec(atom.config.get('linter-terraform-syntax.terraformExecutablePath'), fmtArgs, { cwd: dir });
125+
helpers.exec(atom.config.get('linter-terraform-syntax.terraformExecutablePath'), fmtArgs, { cwd: dir }).catch(error => {
126+
// catch format errors and display as pulsar warning
127+
atom.notifications.addWarning(
128+
'An error occurred during automatic formatting.',
129+
{
130+
detail: error.message,
131+
dismissable: true
132+
}
133+
);
134+
});
126135
}
127136

128137
// execute the linting

0 commit comments

Comments
 (0)