From 5517e9eb0f081217423a2c193eabe2496c08eaab Mon Sep 17 00:00:00 2001 From: nlf Date: Mon, 15 Aug 2022 16:48:54 -0700 Subject: [PATCH] fix: compare to \n instead of os.EOL (#157) * fix: compare to \n instead of os.EOL os.EOL is \r\n in win32, which means this check is pretty much guaranteed to fail in windows * chore: lint --- lib/check/check-changelog.js | 3 +-- lib/util/get-git-url.js | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/check/check-changelog.js b/lib/check/check-changelog.js index dc603ec9..67760d49 100644 --- a/lib/check/check-changelog.js +++ b/lib/check/check-changelog.js @@ -1,5 +1,4 @@ const fs = require('@npmcli/fs') -const { EOL } = require('os') const { join, relative } = require('path') const run = async ({ root, path }) => { @@ -10,7 +9,7 @@ const run = async ({ root, path }) => { if (await fs.exists(changelog)) { const content = await fs.readFile(changelog, { encoding: 'utf8' }) - const mustStart = `# Changelog${EOL}${EOL}#` + const mustStart = `# Changelog\n\n#` if (!content.startsWith(mustStart)) { return { title: `The ${relative(root, changelog)} is incorrect:`, diff --git a/lib/util/get-git-url.js b/lib/util/get-git-url.js index d2262be0..94715b88 100644 --- a/lib/util/get-git-url.js +++ b/lib/util/get-git-url.js @@ -18,7 +18,9 @@ const getRepo = async (path) => { const url = new URL(`https://${domain}`) url.pathname = `/${user}/${project}.git` return url.toString() - } catch {} + } catch { + // errors are ignored + } } module.exports = getRepo