1 | import fs from 'fs'
|
2 |
|
3 | const COMMENT = '// This file is a workaround for a bug in web browsers\' "native"' + '\n' +
|
4 | '// ES6 importing system which is uncapable of importing "*.json" files.' + '\n' +
|
5 | '// https://github.com/catamphetamine/libphonenumber-js/issues/239'
|
6 |
|
7 | const path = process.argv[2]
|
8 | jsonToJs(path)
|
9 |
|
10 | function jsonToJs(path) {
|
11 | let contents = fs.readFileSync(path, 'utf-8')
|
12 | contents = COMMENT + '\n' + 'export default ' + contents
|
13 | fs.writeFileSync(path + '.js', contents)
|
14 | } |
\ | No newline at end of file |