From a5c463603d54d55bcca5fdd4e04117a4d027a3e6 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 30 Jun 2017 22:08:54 +0200 Subject: feat(cli): accept argument for site directory Add a script at the same time to enable using the test files for manual testing --- package.json | 1 + src/index.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 47c3ba5..1bab4eb 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,7 @@ }, "scripts": { "dev": "node-dev .", + "dev:testsite": "node-dev . test/testsite/", "dev:assist": "auto-install --yarn", "format": "prettier-standard 'src/**/*.js' 'test/**/*.js'", "precommit": "lint-staged", diff --git a/src/index.js b/src/index.js index a3e8dea..2c75554 100644 --- a/src/index.js +++ b/src/index.js @@ -1,13 +1,18 @@ -'use strict' +"use strict"; -const config = require('./modules/config.js') +const config = require("./modules/config.js"); -const PORT = process.env.PORT || config.server.port +const PORT = process.env.PORT || config.server.port; +const targetDir = process.argv[2]; -const app = require('./app.js') +if (targetDir) { + process.chdir(targetDir); +} -module.exports = app +const app = require("./app.js"); + +module.exports = app; app.listen(PORT, () => { - console.log(`App listening on port ${PORT}`) -}) + console.log(`App listening on port ${PORT}`); +}); -- cgit 1.4.1