|
1 | 1 | const fs = require('fs-extra') |
2 | | -const { cyan, bold } = require('colorette') |
| 2 | +const { red, cyan, bold } = require('colorette') |
3 | 3 | const { URL } = require('url') |
4 | 4 | const LDP = require('../../lib/ldp') |
5 | 5 | const AccountManager = require('../../lib/models/account-manager') |
@@ -41,7 +41,22 @@ function loadConfig (program, options) { |
41 | 41 | const config = JSON.parse(file) |
42 | 42 | argv = { ...config, ...argv } |
43 | 43 | } catch (err) { |
44 | | - // No file exists, not a problem |
| 44 | + // If config file was specified, but it doesn't exist, stop with error message |
| 45 | + if (typeof argv['configFile'] !== 'undefined') { |
| 46 | + if (!fs.existsSync(configFile)) { |
| 47 | + console.log(red(bold('ERR')), 'Config file ' + configFile + ' doesn\'t exist.') |
| 48 | + process.exit(1) |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + // If the file exists, but parsing failed, stop with error message |
| 53 | + if (fs.existsSync(configFile)) { |
| 54 | + console.log(red(bold('ERR')), 'config file ' + configFile + ' couldn\'t be parsed: ' + err) |
| 55 | + process.exit(1) |
| 56 | + } |
| 57 | + |
| 58 | + // Legacy behavior - if config file does not exist, start with default |
| 59 | + // values, but an info message to create a config file. |
45 | 60 | console.log(cyan(bold('TIP')), 'create a config.json: `$ solid init`') |
46 | 61 | } |
47 | 62 |
|
|
0 commit comments