Skip to content

Commit

Permalink
fix: remove more usage of os.EOL (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
nlf authored Aug 16, 2022
1 parent e095275 commit 4dde648
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/check/check-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const run = async ({ root, path }) => {

if (await fs.exists(changelog)) {
const content = await fs.readFile(changelog, { encoding: 'utf8' })
const mustStart = `# Changelog\n\n#`
if (!content.startsWith(mustStart)) {
const mustStart = /^#\s+Changelog\r?\n\r?\n#/
if (!mustStart.test(content)) {
return {
title: `The ${relative(root, changelog)} is incorrect:`,
body: [
'The changelog should start with',
`"${mustStart}"`,
`"# Changelog\n\n#"`,
],
solution: 'reformat the changelog to have the correct heading',
}
Expand Down
3 changes: 1 addition & 2 deletions lib/check/check-gitignore.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const log = require('proc-log')
const { EOL } = require('os')
const { resolve, relative, basename } = require('path')
const fs = require('@npmcli/fs')
const git = require('@npmcli/git')
Expand Down Expand Up @@ -48,7 +47,7 @@ const run = async ({ root, path, config }) => {

const ignores = (await fs.readFile(ignoreFile))
.toString()
.split(EOL)
.split(/\r?\n/)
.filter((l) => l && !l.trim().startsWith('#'))

const relIgnore = relativeToRoot(ignoreFile)
Expand Down
3 changes: 1 addition & 2 deletions lib/util/parser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const fs = require('@npmcli/fs')
const { EOL } = require('os')
const { basename, extname, dirname } = require('path')
const yaml = require('yaml')
const NpmPackageJson = require('@npmcli/package-json')
Expand Down Expand Up @@ -56,7 +55,7 @@ class Base {

prepare (s) {
const header = this.header()
return header ? header + EOL + EOL + s : s
return header ? `${header}\n\n${s}` : s
}

prepareTarget (s) {
Expand Down

0 comments on commit 4dde648

Please sign in to comment.