From 1ec1d8b0e0f989811f96666185cb7ebea40e0e30 Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 30 Aug 2019 15:03:22 +0200 Subject: [PATCH] make fresh mode the default behaviour --- package.json | 1 + server.js | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 8ed4b4e9d..25f4d173f 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "start": "node server.js", "dev": "DEV=1 node server.js", "fresh": "FRESH=1 node server.js", + "package": "PACKAGE=1 node server.js", "lint": "jshint --config .jshintrc --exclude-path .jshintignore . && ./node_modules/lesshint/bin/lesshint -c ./.lesshintrc ./customize.dist/src/less2/", "lint:js": "jshint --config .jshintrc --exclude-path .jshintignore .", "lint:less": "./node_modules/lesshint/bin/lesshint -c ./.lesshintrc ./customize.dist/src/less2/", diff --git a/server.js b/server.js index 63f5738a2..1d5041549 100644 --- a/server.js +++ b/server.js @@ -38,22 +38,34 @@ var app = debuggable('app', Express()); var httpsOpts; -var DEV_MODE = !!process.env.DEV -if (DEV_MODE) { - console.log("DEV MODE ENABLED"); -} +// mode can be FRESH (default), DEV, or PACKAGE -var FRESH_MODE = !!process.env.FRESH; var FRESH_KEY = ''; -if (FRESH_MODE) { +var FRESH_MODE = true; +var DEV_MODE = false; +if (process.env.PACKAGE) { +// `PACKAGE=1 node server` uses the version string from package.json as the cache string + console.log("PACKAGE MODE ENABLED"); + FRESH_MODE = false; + DEV_MODE = false; +} else if (process.env.DEV) { +// `DEV=1 node server` will use a random cache string on every page reload + console.log("DEV MODE ENABLED"); + FRESH_MODE = false; + DEV_MODE = true; +} else { +// `FRESH=1 node server` will set a random cache string when the server is launched +// and use it for the process lifetime or until it is reset from the admin panel console.log("FRESH MODE ENABLED"); FRESH_KEY = +new Date(); } + config.flushCache = function () { FRESH_KEY = +new Date(); + if (!config.log) { return; } + config.log.info("UPDATING_FRESH_KEY", FRESH_KEY); }; - const clone = (x) => (JSON.parse(JSON.stringify(x))); var setHeaders = (function () {