Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blog archetype has DOS line endings #779

Closed
NatTuck opened this issue Jun 8, 2022 · 10 comments
Closed

Blog archetype has DOS line endings #779

NatTuck opened this issue Jun 8, 2022 · 10 comments

Comments

@NatTuck
Copy link

NatTuck commented Jun 8, 2022

Description

hugo new content/blog/... produces a file with DOS line endings.

This is only an issue for blog posts. The docs archetype is fine.

Steps to reproduce

  • Working in an OS other than Windows
  • Make new site (Child theme)
  • hugo new content/blog/foo/index.md
  • cat -veT content/blog/foo/index.md
---^M$
title: "{{ replace .Name "-" " " | title }}"^M$
description: ""^M$
...

Expected result

No ^M at the end of each line because the file has native line endings.

Actual result

The other thing.

Environment

doks-child-theme@0.4.3 precheck
npm version

{
'doks-child-theme': '0.4.3',
npm: '7.24.1',
node: '14.17.5',
v8: '8.4.371.23-node.76',
uv: '1.41.0',
zlib: '1.2.11',
brotli: '1.0.9',
ares: '1.17.2',
modules: '83',
nghttp2: '1.42.0',
napi: '8',
llhttp: '2.1.3',
openssl: '1.1.1k',
cldr: '39.0',
icu: '69.1',
tz: '2021a',
unicode: '13.0'
}

doks-child-theme@0.4.3 check
exec-bin node_modules/.bin/hugo/hugo version

hugo v0.99.0-1de333e7a3fc863672ec6d6cd53ba66dbcdd2305+extended linux/amd64 BuildDate=2022-05-16T08:10:56Z VendorInfo=gohugoio

$ hugo --version

hugo v0.100.1-0afb4866e345d31cbbcbab4349e43f1d36122806+extended linux/amd64 BuildDate=2022-06-01T10:11:48Z VendorInfo=gohugoio

@h-enk
Copy link
Member

h-enk commented Jun 8, 2022

Thanks for reporting this. I'm not quite sure how to fix this (and I can't use my Manjaro machine right now).

On Windows, in Visual Studio code, I see that both ./archetypes/docs.md and ./archetypes/blog.md (and all other Doks files) use CRLF — so, not LF. Note that, end_of_line = lf in .editorconfig — see also EditorConfig

Could you try with copying ./node_modules/@hyas/doks/archetypes/* to ./archetypes/* (so that the virtual mount is not used)? Or, do you have any other ideas? Thanks!

@NatTuck
Copy link
Author

NatTuck commented Jun 8, 2022

I copied the blog archetype out of node_modules and removed the bad line endings, which fixed it for me for the moment.

Testing again, apparently I was just wrong about the docs archetype being correct. Running npm run create content/docs/foo.md gives me CRs in the resulting file as well.

When I directly clone this repo, I get correct line endings. If I manually npm install @hyas/doks in an empty directory I get DOS line endings under node_modules. That's true for all the .md files in the repo that I checked.

This might be related? npm/npm#2097

@james-d-elliott
Copy link
Contributor

Can you try with that PR? I suspect it should fix it.

@james-d-elliott
Copy link
Contributor

Actually looking again with git ls-files --eol:

i/lf    w/lf    attr/                   archetypes/default.md
i/lf    w/lf    attr/                   archetypes/docs.md
i/lf    w/lf    attr/                   archetypes/docs/_index.md
i/lf    w/lf    attr/                   archetypes/docs/lorem/_index.md
i/lf    w/lf    attr/                   archetypes/docs/lorem/ipsum/index.md

This seems to probably be some form of local issue maybe? The index has these files all ending with LF.

@NatTuck
Copy link
Author

NatTuck commented Jun 12, 2022

I think it's fine in git. My suspicion is that it's a problem with running "npm publish" from Windows, hence only seeing the issue with npm packages and not git checkouts.

@james-d-elliott
Copy link
Contributor

Yeah that's probably more likely the cause. Beyond my knowledge though.

@NatTuck
Copy link
Author

NatTuck commented Jun 12, 2022

Looks like the npm people recommend fixing it in a prepublish hook: npm/npm#12371

@h-enk
Copy link
Member

h-enk commented Jun 14, 2022

Looks like the npm people recommend fixing it in a prepublish hook: npm/npm#12371

Hmm..

Would it be something to try shipping the next version of the Doks themes (both parent and child) using LF (on all files)? See if that helps, or wouldn't that make sense?

I was thinking of converting the line endings with something like sed -i 's/\r$//' **/*.md (et cetera). Or, Nat, do you have ideas for a smarter way to bulk convert? Thanks!

@github-actions
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale label Jul 15, 2022
@github-actions
Copy link
Contributor

This issue was closed because it has been stalled for 5 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants