Skip to content

Commit

Permalink
fix(compat): replace const with var, potentially fixing old browser i…
Browse files Browse the repository at this point in the history
…ssues

fix #71
  • Loading branch information
grantila committed Dec 9, 2021
1 parent d745744 commit 507f250
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"main": "./index.js",
"types": "./index.d.ts",
"scripts": {
"build": "node_modules/.bin/gulp",
"build:libphonenumber": "node_modules/.bin/gulp",
"build:rewrite": "ts-node scripts/rewrite.ts",
"build": "yarn build:libphonenumber && yarn build:rewrite",
"test": "scripts/test.sh",
"cz": "git-cz",
"semantic-release": "semantic-release"
Expand All @@ -41,6 +43,7 @@
"devDependencies": {
"@types/mkdirp": "^1.0.1",
"@types/mocha": "8.2.2",
"@types/node": "^16.11.12",
"chai": "4.3.4",
"commitizen": "^4.2.4",
"cz-conventional-changelog": "^3.3.0",
Expand All @@ -52,6 +55,7 @@
"pre-commit": "1.x",
"replace": "1.2.1",
"rimraf-promise": "2.x",
"ts-node": "^10.4.0",
"typescript": "^4.2.4"
},
"config": {
Expand Down
15 changes: 15 additions & 0 deletions scripts/rewrite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

import { promises } from 'fs'
import * as path from 'path'

const { readFile, writeFile } = promises;

const distFile = path.resolve( __dirname, '..', 'lib', 'index.js' );

async function rewrite( )
{
const data = await readFile( distFile, 'utf-8' );
const res = data.replace( /\bconst /g, 'var ' );
await writeFile( distFile, res, 'utf-8' );
}
rewrite( );

0 comments on commit 507f250

Please sign in to comment.