| // ------------------------------------------------------- | // ------------------------------------------------------- | ||||
| // Configuring the current version of the application. | // Configuring the current version of the application. | ||||
| function GitClean(){ | |||||
| try { | |||||
| exec("git diff --quiet HEAD"); | |||||
| } catch(e) { | |||||
| return false; | |||||
| } | |||||
| return true; | |||||
| } | |||||
| function GenVersion(){ | function GenVersion(){ | ||||
| var v = package.version; | var v = package.version; | ||||
| var clean = GitClean(); | |||||
| // Testing for a GIT repo... if not in a production environment. | // Testing for a GIT repo... if not in a production environment. | ||||
| if (production === false){ | if (production === false){ | ||||
| try{ | try{ | ||||
| v += "-[" + res.trim(); | v += "-[" + res.trim(); | ||||
| res = exec("git rev-parse HEAD").toString(); | res = exec("git rev-parse HEAD").toString(); | ||||
| v += ":" + res.substring(0, 5) + "]"; | |||||
| v += ":" + res.substring(0, 5) + ((clean) ? "" : "-X") + "]"; | |||||
| } catch(e) { | } catch(e) { | ||||
| if (v !== package.version){ | if (v !== package.version){ | ||||
| v += "]"; // If v doesn't match package.version, then assume that the first git call worked. | v += "]"; // If v doesn't match package.version, then assume that the first git call worked. | ||||
| return v; | return v; | ||||
| } | } | ||||
| var version = GenVersion(); | |||||
| // --------------------------------------------------- | // --------------------------------------------------- | ||||
| res.send(new Buffer.from(css_output)); | res.send(new Buffer.from(css_output)); | ||||
| }); | }); | ||||
| app.get('/', function(req, res){ | app.get('/', function(req, res){ | ||||
| res.render('index.html', {version:version, author:package.author}); | |||||
| res.render('index.html', {version:GenVersion(), author:package.author}); | |||||
| }); | }); | ||||
| // -------------------------------------------------- | // -------------------------------------------------- | ||||
| // Announce app version! | // Announce app version! | ||||
| console.log("NESPaint (v" + version + ") Server"); | |||||
| console.log("NESPaint (v" + GenVersion() + ") Server"); | |||||
| // -------------------------------------------------- | // -------------------------------------------------- |