feat(cli): accept argument for site directory Add a script at the same time to enable using the test files for manual testing
Alan Pearce alan@alanpearce.eu
Fri, 30 Jun 2017 22:08:54 +0200
2 files changed, 13 insertions(+), 7 deletions(-)
jump to
M package.json → 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",
M src/index.js → 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]; + +if (targetDir) { + process.chdir(targetDir); +} -const app = require('./app.js') +const app = require("./app.js"); -module.exports = app +module.exports = app; app.listen(PORT, () => { - console.log(`App listening on port ${PORT}`) -}) + console.log(`App listening on port ${PORT}`); +});