-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0aed9b2
commit 87a2a8a
Showing
4 changed files
with
41 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,6 @@ globals: | |
cordova: true | ||
extends: | ||
- airbnb-base | ||
rules: | ||
no-console: 0 | ||
no-useless-escape: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,32 @@ | ||
if(window.location.href.indexOf('chrome') > -1){ | ||
var chokidar = require('chokidar'); | ||
var watcher = chokidar.watch('.', {ignored: /[\/\\]\./}); | ||
var reloading = false; | ||
|
||
function triggerReload(){ | ||
|
||
console.warn('Reloading app...'); | ||
|
||
if(location){ | ||
location.reload(); | ||
} | ||
|
||
const chokidar = require('chokidar'); | ||
|
||
function triggerReload() { | ||
console.warn('Reloading app...'); | ||
|
||
if (location) { | ||
location.reload(); | ||
} | ||
} | ||
|
||
if (window.location.href.indexOf('chrome') > -1) { | ||
const watcher = chokidar.watch('.', { | ||
ignored: /[\/\\]\./, | ||
}); | ||
let reloading = false; | ||
|
||
watcher.on('all', (event, path) => { | ||
if (event === 'change' && path && (path.indexOf('public/') > -1 || path.indexOf('src/') > -1)) { | ||
if (path.indexOf('.css') > -1 || path.indexOf('.scss') > -1) { | ||
const styles = document.querySelectorAll('link[rel=stylesheet]'); | ||
|
||
styles.forEach((style) => { | ||
const restyled = `${style.getAttribute('href')}?v=${Math.floor((Math.random() * 10000) + 1)}`; | ||
style.setAttribute('href', restyled); | ||
}); | ||
} else if (!reloading) { | ||
reloading = true; | ||
setInterval(triggerReload, 100); | ||
} | ||
} | ||
|
||
watcher.on('all', function(event, path) { | ||
if (event == "change" && path && (path.indexOf('public/') > -1 || path.indexOf('src/') > -1)){ | ||
|
||
if(path.indexOf('.css') > -1 || path.indexOf('.scss') > -1){ | ||
var styles = document.querySelectorAll('link[rel=stylesheet]'); | ||
|
||
for (var i = 0; i < styles.length; i++) { | ||
// reload styles | ||
var restyled = styles[i].getAttribute('href') + '?v='+Math.random(0,10000); | ||
styles[i].setAttribute('href', restyled); | ||
} | ||
}else{ | ||
if(!reloading){ | ||
reloading = true; | ||
setInterval(triggerReload, 100); | ||
} | ||
} | ||
} | ||
|
||
}); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const shell = require('shelljs'); | ||
|
||
const getCommitHash = function () { | ||
// exec git command to get the hash of the current commit | ||
// git rev-parse HEAD | ||
const getCommitHash = () => { | ||
// exec git command to get the hash of the current commit | ||
// git rev-parse HEAD | ||
|
||
const hash = shell.exec('git rev-parse HEAD', { | ||
silent: true, | ||
}).output.trim().substr(0, 7); | ||
if (hash === 'fatal: ') { return 'n/a'; } | ||
return hash; | ||
|
||
return (hash === 'fatal: ' ? 'n/a' : hash); | ||
}; | ||
|
||
const commitHash = getCommitHash(); | ||
const json = JSON.parse(fs.readFileSync('./package.json', 'utf8')); | ||
console.log(`v${json.version} #${commitHash}`); | ||
|
||
let content = `window.version="${json.version}";`; | ||
content = `${content}\nwindow.commitHash="${commitHash}";`; | ||
const content = `window.version="${json.version}";\nwindow.commitHash="${commitHash}";`; | ||
fs.writeFileSync('./src/js/version.js', content); |