diff --git a/app.js b/app.js index f7cb031..a91284a 100644 --- a/app.js +++ b/app.js @@ -22,9 +22,16 @@ let fs = require('fs'), path = require('path'); +const commandLineArgs = require('command-line-args'); +const optionDefinitions = [ + { name: 'config', alias: 'c', type: String, defaultValue: './config.json' }, +]; + +const options = commandLineArgs(optionDefinitions); + global.syzoj = { rootDir: __dirname, - config: require('./config.json'), + config: require(options.config), models: [], modules: [], db: null, diff --git a/package-lock.json b/package-lock.json index 6001afa..18c4566 100644 --- a/package-lock.json +++ b/package-lock.json @@ -87,6 +87,14 @@ "sprintf-js": "1.0.3" } }, + "array-back": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-2.0.0.tgz", + "integrity": "sha512-eJv4pLLufP3g5kcZry0j6WXpIbzYw9GUB4mVJZno9wfwiBxbizTnHCw3VJb07cBihbFX48Y7oSrW9y+gt4glyw==", + "requires": { + "typical": "2.6.1" + } + }, "array-equal": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz", @@ -364,6 +372,16 @@ "delayed-stream": "1.0.0" } }, + "command-line-args": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/command-line-args/-/command-line-args-4.0.7.tgz", + "integrity": "sha512-aUdPvQRAyBvQd2n7jXcsMDz68ckBJELXNzBybCHOibUWEg0mWTnaYCSRU8h9R+aNRSvDihJtssSRCiDRpLaezA==", + "requires": { + "array-back": "2.0.0", + "find-replace": "1.0.3", + "typical": "2.6.1" + } + }, "commander": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", @@ -979,6 +997,25 @@ "unpipe": "1.0.0" } }, + "find-replace": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-1.0.3.tgz", + "integrity": "sha1-uI5zZNLZyVlVnziMZmcNYTBEH6A=", + "requires": { + "array-back": "1.0.4", + "test-value": "2.1.0" + }, + "dependencies": { + "array-back": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz", + "integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=", + "requires": { + "typical": "2.6.1" + } + } + } + }, "find-up": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", @@ -3627,6 +3664,25 @@ "terraformer": "1.0.8" } }, + "test-value": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/test-value/-/test-value-2.1.0.tgz", + "integrity": "sha1-Edpv9nDzRxpztiXKTz/c97t0gpE=", + "requires": { + "array-back": "1.0.4", + "typical": "2.6.1" + }, + "dependencies": { + "array-back": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/array-back/-/array-back-1.0.4.tgz", + "integrity": "sha1-ZEun8JX3/898Q7Xw3DnTwfA8Bjs=", + "requires": { + "typical": "2.6.1" + } + } + } + }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -3758,6 +3814,11 @@ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, + "typical": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/typical/-/typical-2.6.1.tgz", + "integrity": "sha1-XAgOXWYcu+OCWdLnCjxyU+hziB0=" + }, "uid-safe": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.4.tgz", diff --git a/package.json b/package.json index 12a731b..4c6f436 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "async-lock": "^0.3.9", "body-parser": "^1.15.2", "cheerio": "^1.0.0-rc.1", + "command-line-args": "^4.0.7", "cookie-parser": "^1.4.3", "cssfilter": "0.0.10", "csurf": "^1.9.0",