ember-cli-moment-shim
Advanced tools
Comparing version 3.5.2 to 3.5.3
96
index.js
@@ -32,3 +32,3 @@ /* globals require, module, process */ | ||
if (this._options.includeTimezone) { | ||
target = 'fastboot-moment-timezone.js' | ||
target = 'fastboot-moment-timezone.js'; | ||
} | ||
@@ -65,3 +65,5 @@ | ||
options.includeLocales.forEach(locale => { | ||
this.import('vendor/moment/locales/' + locale + '.js', { prepend: true }); | ||
this.import('vendor/moment/locales/' + locale + '.js', { | ||
prepend: true | ||
}); | ||
}); | ||
@@ -81,3 +83,4 @@ } | ||
getOptions() { | ||
let projectConfig = (this.project.config(process.env.EMBER_ENV) || {}).moment || {}; | ||
let projectConfig = | ||
(this.project.config(process.env.EMBER_ENV) || {}).moment || {}; | ||
let momentPath = path.dirname(require.resolve('moment')); | ||
@@ -93,3 +96,8 @@ let config = defaults(projectConfig, { | ||
.filter(locale => typeof locale === 'string') | ||
.map(locale => locale.replace('.js', '').trim().toLowerCase()) | ||
.map(locale => | ||
locale | ||
.replace('.js', '') | ||
.trim() | ||
.toLowerCase() | ||
) | ||
.filter(locale => { | ||
@@ -120,3 +128,5 @@ if (locale === 'en') { | ||
treeForPublic() { | ||
let hasFastBoot = this.project.addons.some(addon => addon.name === 'ember-cli-fastboot'); | ||
let hasFastBoot = this.project.addons.some( | ||
addon => addon.name === 'ember-cli-fastboot' | ||
); | ||
let publicTree = this._super.treeForPublic.apply(this, arguments); | ||
@@ -141,25 +151,2 @@ let options = this._options; | ||
}, | ||
pathsForOptions({ includeTimezone }) { | ||
switch (includeTimezone) { | ||
case 'all': | ||
return ['builds/moment-timezone-with-data.js', 'builds/moment-timezone-with-data.min.js']; | ||
case '2010-2020': | ||
this.ui.writeLine( | ||
chalk.yellow( | ||
'[ember-cli-moment-shim] "2010-2020" is deprecated, use "subset" within config/environment\nDiscussion: https://github.com/jasonmit/ember-cli-moment-shim/issues/121' | ||
) | ||
); | ||
case 'subset': | ||
case '2012-2022': | ||
case '2010-2020': | ||
return ['builds/moment-timezone-with-data-*.js', 'builds/moment-timezone-with-data-*.min.js']; | ||
case 'none': | ||
return ['moment-timezone.js', 'builds/moment-timezone.min.js']; | ||
default: | ||
throw new Error( | ||
'ember-cli-moment-shim: Please specify the moment-timezone dataset to include as either "all", "subset", or "none".' | ||
); | ||
} | ||
}, | ||
@@ -178,11 +165,18 @@ treeForVendor(vendorTree) { | ||
include: [new RegExp(/\.js$/)], | ||
exclude: ['tests', 'ender', 'package'].map(key => new RegExp(key + '\.js$')) | ||
exclude: ['tests', 'ender', 'package'].map( | ||
key => new RegExp(key + '.js$') | ||
) | ||
}) | ||
); | ||
if (Array.isArray(options.includeLocales) && options.includeLocales.length) { | ||
if ( | ||
Array.isArray(options.includeLocales) && | ||
options.includeLocales.length | ||
) { | ||
let localeTree = funnel(this.momentNode, { | ||
srcDir: 'locale', | ||
destDir: 'moment/locales', | ||
include: options.includeLocales.map(locale => new RegExp(locale + '\.js$')) | ||
include: options.includeLocales.map( | ||
locale => new RegExp(locale + '.js$') | ||
) | ||
}); | ||
@@ -194,5 +188,36 @@ | ||
if (options.includeTimezone) { | ||
let [ timezonePath, timezoneMinPath ] = this.pathsForOptions(options); | ||
let timezoneNode = new UnwatchedDir(path.dirname(require.resolve('moment-timezone'))); | ||
let timezonePath; | ||
let timezoneMinPath; | ||
switch (options.includeTimezone) { | ||
case 'all': | ||
timezonePath = 'builds/moment-timezone-with-data.js'; | ||
timezoneMinPath = 'builds/moment-timezone-with-data.min.js'; | ||
break; | ||
case '2010-2020': | ||
this.ui.writeLine( | ||
chalk.yellow( | ||
'[ember-cli-moment-shim] "2010-2020" is deprecated, use "subset" within config/environment\nDiscussion: https://github.com/jasonmit/ember-cli-moment-shim/issues/121' | ||
) | ||
); | ||
case 'subset': | ||
case '2012-2022': | ||
case '2010-2020': | ||
timezonePath = 'builds/moment-timezone-with-data-*.js'; | ||
timezoneMinPath = 'builds/moment-timezone-with-data-*.min.js'; | ||
break; | ||
case 'none': | ||
timezonePath = 'moment-timezone.js'; | ||
timezoneMinPath = 'builds/moment-timezone.min.js'; | ||
break; | ||
default: | ||
throw new Error( | ||
'ember-cli-moment-shim: Please specify the moment-timezone dataset to include as either "all", "subset", or "none".' | ||
); | ||
} | ||
const timezoneNode = new UnwatchedDir( | ||
path.dirname(require.resolve('moment-timezone')) | ||
); | ||
trees.push( | ||
@@ -213,4 +238,7 @@ rename( | ||
return map(mergeTrees(trees), (content) => `if (typeof FastBoot === 'undefined') { ${content} }`); | ||
return map( | ||
mergeTrees(trees), | ||
content => `if (typeof FastBoot === 'undefined') { ${content} }` | ||
); | ||
} | ||
}; |
{ | ||
"name": "ember-cli-moment-shim", | ||
"version": "3.5.2", | ||
"version": "3.5.3", | ||
"description": "Brings moment and moment-timezone into your Ember applications", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
211505
242