Skip to content

Commit

Permalink
safeguard auto-format warns to non-config files
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuchard committed Aug 6, 2024
1 parent ed1f5be commit 3ee9722
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
### (Next)
### 1.6.3 (Next)
- Warn on automatic formatting errors returned for non-config Terraform files.

### 1.6.2
- Refactor auto formatting config options.
Expand Down
19 changes: 11 additions & 8 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,17 @@ export default {

// auto-format the target
helpers.exec(atom.config.get('linter-terraform-syntax.terraformExecutablePath'), fmtArgs, { cwd: dir }).catch(error => {
// catch format errors and display as pulsar warning
atom.notifications.addWarning(
'An error occurred during automatic formatting.',
{
detail: error.message,
dismissable: true
}
);
// verify this is not a config file since validate returns for those files
if (!(/\.tf$/.exec(editorFile))) {
// catch format errors and display as pulsar warning
atom.notifications.addWarning(
'An error occurred during automatic formatting.',
{
detail: error.message,
dismissable: true
}
);
}
});
}

Expand Down

0 comments on commit 3ee9722

Please sign in to comment.