Skip to content

Commit

Permalink
build: add umd build name
Browse files Browse the repository at this point in the history
  • Loading branch information
iamkun committed May 15, 2018
1 parent a09c52d commit 0820193
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const { promisify } = util

const promisifyReadDir = promisify(fs.readdir)

const formatName = n => n.replace(/\.js/, '').replace('-', '_')

async function build(option) {
const bundle = await rollup.rollup(option.input)
await bundle.write(option.output)
Expand All @@ -20,7 +22,7 @@ async function build(option) {
build(configFactory({
input: `./src/locale/${l}`,
fileName: `./locale/${l}`,
name: `dayjs-locale-${l}`
name: `dayjs_locale_${formatName(l)}`
}))
})

Expand All @@ -29,7 +31,7 @@ async function build(option) {
build(configFactory({
input: `./src/plugin/${l}`,
fileName: `./plugin/${l}`,
name: `dayjs-plugin-${l}`
name: `dayjs_plugin_${formatName(l)}`
}))
})

Expand Down
2 changes: 1 addition & 1 deletion karma.sauce.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ module.exports = function (config) {
basePath: '',
frameworks: ['jasmine'],
files: [
'dist/*.js',
'dayjs.min.js',
'test/*spec.js'
],
reporters: ['dots', 'saucelabs'],
Expand Down
5 changes: 2 additions & 3 deletions src/plugin/advancedFormat.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import dayjs from 'dayjs'
import { FORMAT_DEFAULT } from '../constant'

dayjs.extend((o, c, d) => { // locale needed later
export default (o, c, d) => { // locale needed later
const proto = c.prototype
const oldFormat = proto.format
// eslint-disable-next-line no-nested-ternary
Expand Down Expand Up @@ -29,5 +28,5 @@ dayjs.extend((o, c, d) => { // locale needed later
})
return oldFormat.bind(this)(result, locale)
}
})
}

4 changes: 3 additions & 1 deletion test/plugin/advancedFormat.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import MockDate from 'mockdate'
import moment from 'moment'
import dayjs from '../../src'
import '../../src/plugin/advancedFormat'
import advancedFormat from '../../src/plugin/advancedFormat'

dayjs.extend(advancedFormat)

beforeEach(() => {
MockDate.set(new Date())
Expand Down

0 comments on commit 0820193

Please sign in to comment.