Skip to content

Commit

Permalink
build: update locale import path in esm
Browse files Browse the repository at this point in the history
fix #501
  • Loading branch information
iamkun committed Feb 23, 2019
1 parent 6b555bf commit 9815467
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions build/esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const fs = require('fs')
const path = require('path')
const util = require('util')

const { promisify } = util

const localeDir = path.join(process.env.PWD, 'esm/locale');

(async () => {
try {
const readLocaleDir = await promisify(fs.readdir)(localeDir)
readLocaleDir.forEach(async (l) => {
const filePath = path.join(localeDir, l)
const readFile = await promisify(fs.readFile)(filePath, 'utf8')
const result = readFile.replace("'dayjs'", "'../index'")
await promisify(fs.writeFile)(filePath, result, 'utf8')
})
} catch (e) {
console.error(e)
}
})()
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"test-tz": "jest test/timezone.test --coverage=false",
"lint": "./node_modules/.bin/eslint src/* test/* build/*",
"prettier": "prettier --write \"docs/**/*.md\"",
"babel": "cross-env BABEL_ENV=build babel src --out-dir esm --copy-files",
"babel": "cross-env BABEL_ENV=build babel src --out-dir esm --copy-files && node build/esm",
"build": "cross-env BABEL_ENV=build node build && npm run size",
"sauce": "npx karma start karma.sauce.conf.js",
"test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2 && npm run sauce -- 3",
Expand Down

0 comments on commit 9815467

Please sign in to comment.