Skip to content

Commit 3ee9722

Browse files
committed
safeguard auto-format warns to non-config files
1 parent ed1f5be commit 3ee9722

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
### (Next)
1+
### 1.6.3 (Next)
2+
- Warn on automatic formatting errors returned for non-config Terraform files.
23

34
### 1.6.2
45
- Refactor auto formatting config options.

lib/main.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,17 @@ export default {
123123

124124
// auto-format the target
125125
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-
);
126+
// verify this is not a config file since validate returns for those files
127+
if (!(/\.tf$/.exec(editorFile))) {
128+
// catch format errors and display as pulsar warning
129+
atom.notifications.addWarning(
130+
'An error occurred during automatic formatting.',
131+
{
132+
detail: error.message,
133+
dismissable: true
134+
}
135+
);
136+
}
134137
});
135138
}
136139

0 commit comments

Comments
 (0)