Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "kongfig", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A tool for Kong to allow declarative configuration.", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/mybuilder/kongfig", |
@@ -6,8 +6,14 @@ import execute from 'core'; | ||
const argv = require('minimist')(process.argv.slice(2)); | ||
const argv = require('minimist')(process.argv.slice(2), { string: ['path', 'host'] }); | ||
if (!argv.path) { | ||
throw new Error('--path to the config file is required'); | ||
console.log('--path to the config file is required'.red); | ||
process.exit(1); | ||
} | ||
if (!fs.existsSync(argv.path)) { | ||
console.log(`Supplied --path '${argv.path}' doesn't exist`.red); | ||
process.exit(1); | ||
} | ||
var config = JSON.parse(fs.readFileSync(argv.path)); | ||
@@ -18,9 +24,10 @@ | ||
if (!host) { | ||
throw new Error('Kong admin host must be specified in config or --host'); | ||
console.log('Kong admin host must be specified in config or --host'.red); | ||
process.exit(1); | ||
} | ||
execute(config, adminApi(host)) | ||
.catch(function(error) { | ||
console.log(('' + error).red); | ||
.catch(error => { | ||
console.log(`${error}`.red); | ||
process.exit(1); | ||
}); |
@@ -76,3 +76,3 @@ 'use strict'; | ||
.then(content => { | ||
throw new Error(`${response.statusText}`, JSON.parse(content)); | ||
throw new Error(`${response.statusText}\n${content}`); | ||
}); | ||
@@ -79,0 +79,0 @@ } else { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1350975
26980