From 9eed675e519aa88ecb87fecc8e1f42e4c55ef395 Mon Sep 17 00:00:00 2001 From: Ivan Akulov Date: Sat, 24 Mar 2018 18:34:44 +0300 Subject: [PATCH] Fix the unknown locale warning with Moment 2.21.0 --- index.js | 8 +++++++- package-lock.json | 3 +-- package.json | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 2ed93de..9b96e25 100644 --- a/index.js +++ b/index.js @@ -50,7 +50,13 @@ function normalizeLocalesToKeep(localesToKeep) { // Check if has unknown locales var absentLocales = localesToKeep.filter(function(localeName) { - return moment.localeData(localeName) === null; + const localeData = moment.localeData(localeName); + return ( + // For Moment 2.20.1− + localeData === null || + // For Moment. 2.21.0+ – this version now returns a default locale instead of null + localeData === moment.localeData() + ); }); if (absentLocales.length > 0) { throw new Error( diff --git a/package-lock.json b/package-lock.json index 82acad0..4785c27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1470,8 +1470,7 @@ "jsbn": { "version": "0.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "json-schema": { "version": "0.2.3", diff --git a/package.json b/package.json index d5e4692..0718d4b 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ }, "devDependencies": { "jest": "^22.1.1", - "moment": "^2.20.1", + "moment": "^2.21.0", "proxyquire": "^2.0.1", "temp-dir": "^1.0.0", "webpack": "^4.2.0"