-
Notifications
You must be signed in to change notification settings - Fork 5
/
update.mjs
26 lines (20 loc) · 992 Bytes
/
update.mjs
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
import shell from 'shelljs'
import { mkdir, readFileSync, writeFileSync } from 'fs'
const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url)))
const upkgName = Object.keys(pkg.devDependencies).find(k => /@unicode/.test(k));
const upkgPath = `node_modules/${upkgName}`;
console.log(upkgPath);
shell.rm('-rf', 'properties');
shell.rm('-rf', 'categories');
function pick(from, to) {
shell.mkdir('-p', to);
const src = readFileSync(`${from}/regex.js`, 'utf8');
const out = src.replace('module.exports=', 'export default ');
writeFileSync(`${to}/regex.mjs`, out, 'utf8');
}
pick(`${upkgPath}//Binary_Property/Any`, 'properties/Any/');
pick(`${upkgPath}//General_Category/Control`, 'categories/Cc/');
pick(`${upkgPath}//General_Category/Format`, 'categories/Cf/');
pick(`${upkgPath}//General_Category/Separator`, 'categories/Z/');
pick(`${upkgPath}//General_Category/Punctuation`, 'categories/P/');
pick(`${upkgPath}//General_Category/Symbol`, 'categories/S/');