From 0684a1ea972f6e52bbe3de8100690238d88f8d60 Mon Sep 17 00:00:00 2001 From: Eugene Terehov Date: Wed, 1 Sep 2021 21:03:17 +0300 Subject: [PATCH] Revert support for Node.js 10 (since its only goig to be a patch version. Support for Node.js 10 will be dropped in the next major version) --- .nvmrc | 2 +- .travis.yml | 1 + package.json | 2 +- tests/settings.test.ts | 28 +++++++++++++++++++++++----- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.nvmrc b/.nvmrc index 8351c193..48082f72 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -14 +12 diff --git a/.travis.yml b/.travis.yml index ad957343..ec537d5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,7 @@ node_js: - "16" - "14" - "12" + - "10" install: - npm install diff --git a/package.json b/package.json index 030011e6..4ab6fdb9 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "module": "./dist/esm/index.js", "types": "./dist/types/index.d.ts", "engines": { - "node": ">=12" + "node": ">=10" }, "scripts": { "ts-node": "ts-node example/index.ts", diff --git a/tests/settings.test.ts b/tests/settings.test.ts index 06e1a40d..33ddac04 100644 --- a/tests/settings.test.ts +++ b/tests/settings.test.ts @@ -281,8 +281,10 @@ describe("Logger: settings", () => { const logger: Logger = new Logger({ stdOut: std }); logger.info("test 123"); - const [, , , , , , { value: hour }, , { value: minute }] = - new Intl.DateTimeFormat("en", { + let options = {}; + // hourCycle only supported > Node.js 10 + if (process.version.indexOf("v10") > -1) { + options = { weekday: undefined, year: "numeric", month: "2-digit", @@ -292,7 +294,23 @@ describe("Logger: settings", () => { minute: "2-digit", second: "2-digit", timeZone: "utc", - }).formatToParts(new Date()); + }; + } else { + options = { + weekday: undefined, + year: "numeric", + month: "2-digit", + day: "2-digit", + hourCycle: "h23", + hour: "2-digit", + minute: "2-digit", + second: "2-digit", + timeZone: "utc", + }; + } + + const [, , , , , , { value: hour }, , { value: minute }] = + new Intl.DateTimeFormat("en", options).formatToParts(new Date()); expect(doesLogContain(stdArray, `${hour}:${minute}`)).toBeTruthy(); }); @@ -316,11 +334,11 @@ describe("Logger: settings", () => { year: "numeric", month: "2-digit", day: "2-digit", - hour12: false, + hourCycle: "h23", hour: "2-digit", minute: "2-digit", second: "2-digit", - timeZone: timezone, + timeZone: "Europe/Berlin", }).formatToParts(new Date()); expect(doesLogContain(stdArray, `${hour}:${minute}`)).toBeTruthy(); });