Glavin001 / atom-beautify

:mega: Help Wanted - Looking for Maintainer: https://github.com/Glavin001/atom-beautify/issues/2572 | :lipstick: Universal beautification package for Atom editor (:warning: Currently migrating to https://github.com/Unibeautify/ and have very limited bandwidth for Atom-Beautify Issues. Thank you for your patience and understanding :heart: )
http://unibeautify.com/
MIT License
1.5k stars 453 forks source link

Terraform Fmt failing on .tf files #2348

Open samparnell opened 5 years ago

samparnell commented 5 years ago

Description

Getting this error message when beautifying a .tf file: "Only .tf and .tfvars files can be processed with terraform fmt"

Happening for all my .tf files.

Steps to Reproduce

  1. Add code to Atom editor
  2. Run command Atom Beautify: Beautify Editor
  3. Error is displayed

Package version: 0.33.4 Atom version: 1.37.0 OSX version: 10.14.5 Beatify on other file types seems to work fine.

Stack trace

Error: 
Error: Only .tf and .tfvars files can be processed with terraform fmt

    at /Users/username/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:183:23
    at tryCatcher (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:694:18)
    at _drainQueueStep (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:147:5)
    at Async.drainQueues (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:17:14)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Checklist

I have:

calvinbui commented 5 years ago

Same for me on terraform 0.12

lmasaya commented 5 years ago

I have the same issue. Package version: 0.33.4 Atom version: 1.40.1 x64 OSX version: 10.13.6

Also failed beautifying my terraform code.


Severity    Provider    Description Line 
 Error: Only .tf and .tfvars files can be processed with terraform fmt




Error: Only .tf and .tfvars files can be processed with terraform fmt

Hide Stack Trace
Error: 
Error: Only .tf and .tfvars files can be processed with terraform fmt

    at /Users/username/.atom/packages/atom-beautify/src/beautifiers/executable.coffee:183:23
    at tryCatcher (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:574:18)
    at Promise._settlePromise0 (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:619:10)
    at Promise._settlePromises (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/promise.js:699:18)
    at _drainQueueStep (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:147:5)
    at Async.drainQueues (/Users/username/.atom/packages/atom-beautify/node_modules/bluebird/js/release/async.js:17:14)
    at run (/Users/username/.atom/packages/git-plus/node_modules/core-js/modules/es6.promise.js:75:22)
    at /Users/username/.atom/packages/git-plus/node_modules/core-js/modules/es6.promise.js:92:30
    at flush (/Users/username/.atom/packages/git-plus/node_modules/core-js/modules/_microtask.js:18:9)
    at process._tickCallback (internal/process/next_tick.js:61:11)
mbukosky commented 5 years ago

+1

devboxtesting commented 5 years ago

+1

Gowiem commented 5 years ago

+1

itsSaad commented 5 years ago

Is there any update on this to be fixed?

davidpoltorak commented 4 years ago

+1

masoodazizi commented 4 years ago

+1

Ati59 commented 4 years ago

+1

schelkanov commented 4 years ago

+1

tb102122 commented 4 years ago

Is there any solution for this problem by now?

doublethink13 commented 4 years ago

+1

rtizzy commented 4 years ago

image

Sounds like he may be working on another project.

I've switched to Visual Studio Code and will likely stay. Worth giving a go.

liath commented 4 years ago

FWIW you can apply the fix from the PR yourself by editing %HOMEPATH%\.atom\packages\atom-beautify\src\beautifiers\terraformfmt.coffee

  beautify: (text, language, options) ->
    @exe("terraform").run([
      "fmt"
-      tempFile = @tempFile("input", text)
+      tempFile = @tempFile("input", text, ".tf")
      ])
liath commented 4 years ago

Might I also highly recommend you add -no-color to the args to make the lint messages more readable. (The garbage chars are from Terraform trying to add pretty shell colors)

  beautify: (text, language, options) ->
    @exe("terraform").run([
      "fmt"
+     "-no-color"
      tempFile = @tempFile("input", text, ".tf")
      ])
lmasaya commented 4 years ago

FWIW you can apply the fix from the PR yourself by editing %HOMEPATH%\.atom\packages\atom-beautify\src\beautifiers\terraformfmt.coffee

  beautify: (text, language, options) ->
    @exe("terraform").run([
      "fmt"
-      tempFile = @tempFile("input", text)
+      tempFile = @tempFile("input", text, ".tf")
      ])

Both this and your "-no-color" tip worked great for me. Thanks. Maybe it's time to submit a PR.

liath commented 4 years ago

@lmasaya It already is actually, just needs a merge https://github.com/Glavin001/atom-beautify/pull/2351/files

liath commented 4 years ago

Minus the no-color flag, but somehow I think this project is abandoned now.