Giter Club home page Giter Club logo

Comments (8)

braydonk avatar braydonk commented on May 18, 2024 1

This seems to be a Windows-specific issue. Gotta be some kind of CRLF problem if I had to guess. I'll keep looking into it.

from yamlfmt.

braydonk avatar braydonk commented on May 18, 2024 1

I managed to find the problem in the parser code too. Opened go-yaml/yaml#893 and go-yaml/yaml#894

from yamlfmt.

sharuzzaman avatar sharuzzaman commented on May 18, 2024 1

I would like to update that this issue is not happening again and the hotfix is working correctly. Thank you

from yamlfmt.

braydonk avatar braydonk commented on May 18, 2024

Hi @sharuzzaman,

Unfortunately at this time there aren't a ton of configuration options, so you wouldn't be able to configure a behaviour like this for the time being.

However, I'm unable to reproduce this behaviour locally at the moment. I tried copying the yaml from the first block into a file on its own and it did not insert the newlines as you've mentioned.

x.yaml:

---
Resources:
  ElasticBeanstalk:
    Type: AWS::CloudFormation::Stack
    Properties:
      #NotificationARNs: 
      #  - String
      #Parameters: 
      #  Key : Value
      #Tags: 
      #  - Tag
      TemplateURL: https://examplebucket.s3.ap-southeast-1.amazonaws.com/example-file.json
      TimeoutInMinutes: 5

Piping it into stdin:

braydonk@bk:~/Git/yamlfmt$ cat x.yaml | yamlfmt -
---
Resources:
  ElasticBeanstalk:
    Type: AWS::CloudFormation::Stack
    Properties:
      #NotificationARNs: 
      #  - String
      #Parameters: 
      #  Key : Value
      #Tags: 
      #  - Tag
      TemplateURL: https://examplebucket.s3.ap-southeast-1.amazonaws.com/example-file.json
      TimeoutInMinutes: 5

There's a chance this is a platform issue. I'm running this on Linux. What operating system are you on?

from yamlfmt.

sharuzzaman avatar sharuzzaman commented on May 18, 2024

I'm running yamlfmt on Windows 10 using the Windows command line

from yamlfmt.

braydonk avatar braydonk commented on May 18, 2024

This is tough. It's a combination of 2 bugs in yaml.v3, one is pretty simple and one is not.

yaml.Encoder always writes \n, I'll make a PR upstream that makes it configurable to write \r\n instead

When the parser scans a head comment ending in \r\n, if the next line is anything but another line break, it inserts an extra line. This is deep in the parser code, and won't be fast to solve...

The silver lining is that this is not a universal Windows issue, this is particularly with CRLF line endings. That is a possible workaround if you are flexible with line endings in your project. Regardless, I'll do what I can to get this solved.

from yamlfmt.

braydonk avatar braydonk commented on May 18, 2024

For the line ending problem, I opened go-yaml/yaml#891 and a PR for it go-yaml/yaml#892

from yamlfmt.

braydonk avatar braydonk commented on May 18, 2024

I've opened a hotfix for the behaviour while waiting for the upstream stuff to get fixed, and that's what will go in v0.3.0 so that Windows users can be fixed sooner.

from yamlfmt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.