From eba57e900f6788c58a4d077c6f15b36bd4d1ffe0 Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sun, 12 Jan 2020 22:29:12 -0500 Subject: [PATCH 1/3] Downgrade to yn v3 to avoid v4's node 10 requirement --- package.json | 2 +- src/index.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index df977e0b3..5a76795cb 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,6 @@ "diff": "^4.0.1", "make-error": "^1.1.1", "source-map-support": "^0.5.6", - "yn": "^4.0.0" + "yn": "3.1.1" } } diff --git a/src/index.ts b/src/index.ts index 790c36f9a..c037cc78a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import { relative, basename, extname, resolve, dirname, join } from 'path' import sourceMapSupport = require('source-map-support') -import * as yn from 'yn' +import * as ynModule from 'yn' import { BaseError } from 'make-error' import * as util from 'util' import * as _ts from 'typescript' @@ -26,6 +26,15 @@ declare global { */ export const INSPECT_CUSTOM = util.inspect.custom || 'inspect' +/** + * Wrapper around yn module that returns `undefined` instead of `null`. + * This is implemented by yn v4, but we're staying on v3 to avoid v4's node 10 requirement. + */ +function yn (value: string | undefined) { + const parsed = ynModule(value) + return parsed === null ? undefined : parsed +} + /** * Debugging `ts-node`. */ From cb26bd8573a1c81b245486dabb6f4b4002b9c5cb Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Sun, 12 Jan 2020 22:34:42 -0500 Subject: [PATCH 2/3] update package-lock.json --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 932afdb03..49a55b1f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2090,9 +2090,9 @@ } }, "yn": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yn/-/yn-4.0.0.tgz", - "integrity": "sha512-huWiiCS4TxKc4SfgmTwW1K7JmXPPAmuXWYy4j9qjQo4+27Kni8mGhAAi1cloRWmBe2EqcLgt3IGqQoRL/MtPgg==" + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", + "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==" } } } From 2a2d4d24d90992885bfa92b6c92402b6b2a7aa6f Mon Sep 17 00:00:00 2001 From: Andrew Bradley Date: Mon, 13 Jan 2020 09:56:44 -0500 Subject: [PATCH 3/3] Switch to nullish coalescing --- src/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index c037cc78a..885b0b819 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,8 +31,7 @@ export const INSPECT_CUSTOM = util.inspect.custom || 'inspect' * This is implemented by yn v4, but we're staying on v3 to avoid v4's node 10 requirement. */ function yn (value: string | undefined) { - const parsed = ynModule(value) - return parsed === null ? undefined : parsed + return ynModule(value) ?? undefined } /**