Skip to content

Commit

Permalink
Fix the unknown locale warning with Moment 2.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
iamakulov committed Mar 24, 2018
1 parent 8d98386 commit 9eed675
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9eed675

Please sign in to comment.