Skip to content

Commit

Permalink
Merge pull request #91 from AssetMantle/0xnkit/versionUpdate
Browse files Browse the repository at this point in the history
fixed auto version update
  • Loading branch information
avkr003 authored Mar 29, 2022
2 parents 6ff9cec + 5884af5 commit 23b2327
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@testing-library/user-event": "^12.1.10",
"bootstrap": "^4.6.0",
"cosmjs-types": "^0.4.1",
"dotenv-cli": "^5.1.0",
"i18next": "^21.6.11",
"i18next-browser-languagedetector": "^6.1.3",
"react": "^17.0.2",
Expand All @@ -26,10 +27,10 @@
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"start": "REACT_APP_VERSION=$(git describe --tags --abbrev=0) react-scripts start",
"build": "REACT_APP_VERSION=$(git describe --tags --abbrev=0) react-scripts build",
"test": "REACT_APP_VERSION=$(git describe --tags --abbrev=0) react-scripts test",
"eject": "REACT_APP_VERSION=$(git describe --tags --abbrev=0) react-scripts eject"
},
"eslintConfig": {
"extends": [
Expand Down
22 changes: 3 additions & 19 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,9 @@ const App = () => {
const location = useLocation();

// changing header
function compareVersion(currentVersion, version) {
let currentVersionList = currentVersion.split("v");
let current = currentVersionList[1].split(".");
let versionList = version.split("v");
let oldVersion = versionList[1].split(".");
if (
current[0] * 1000 + current[1] * 100 + current[2] * 10 >
oldVersion[0] * 1000 + oldVersion[1] * 100 + oldVersion[2] * 10
) {
return true;
} else {
return false;
}
}
const CURRENT_VERSION = "v0.2.3";
if (
localStorage.getItem("VERSION") == null ||
compareVersion(CURRENT_VERSION, localStorage.getItem("VERSION"))
) {
const CURRENT_VERSION = process.env.REACT_APP_VERSION
if (localStorage.getItem("VERSION") !== CURRENT_VERSION){

localStorage.clear();
localStorage.setItem("VERSION", CURRENT_VERSION);
window.location.reload();
Expand Down

0 comments on commit 23b2327

Please sign in to comment.