forked from kenhyuwa/litepie-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exec.js
27 lines (24 loc) · 775 Bytes
/
exec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const path = require('path');
const fs = require('fs-extra');
const dayjsLocale = './node_modules/dayjs/esm/locale';
const localeSrc = './src/locale';
async function main() {
await fs.remove(localeSrc);
const locales = await fs.readdir(dayjsLocale);
for (const locale of locales) {
await fs.copySync(
`${dayjsLocale}/${locale}`,
path.join(__dirname, `./src/locale/${locale}`)
);
await fs.readFile(`${localeSrc}/${locale}`, 'utf8', function(err, data) {
if (err) return console.log(err);
const result = data.replace(/..\/index/g, 'dayjs');
fs.writeFile(`${localeSrc}/${locale}`, result, 'utf8', function(err) {
if (err) return console.log(err);
});
});
}
}
main().catch(err => {
console.error(err);
});