Skip to content

Commit

Permalink
fix: review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
msagi committed Apr 19, 2024
1 parent 45fe5e5 commit f9c456d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ const argv = require('yargs/yargs')(process.argv.slice(2))
})
.strict().argv;

require('./src/config/file').configFile = argv.c ? argv.c : undefined;
const config = require('./src/config/file');
config.configFile = argv.c ? argv.c : undefined;

if (argv.v) {
const fs = require('fs');
const config = require('./src/config/file');

if (!fs.existsSync(config.configFile)) {
console.error(
Expand All @@ -36,6 +36,8 @@ if (argv.v) {
process.exit(0);
}

config.validate();

const proxy = require('./src/proxy');
const service = require('./src/service');

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 5 additions & 2 deletions test/testConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ const chai = require('chai');
const fs = require('fs');
const path = require('path');
const defaultSettings = require('../proxy.config.json');
const fixtures = 'fixtures';

chai.should();
const expect = chai.expect;

describe('default configuration', function () {
it('should use default values if no user-settings.json file exists', function () {
const config = require('../src/config');
config.logConfiguration();

expect(config.getAuthentication()).to.be.eql(
defaultSettings.authentication[0],
Expand Down Expand Up @@ -123,7 +125,8 @@ describe('validate config files', function () {
'proxy.config.valid-2.json',
];
for (const testConfigFile of validConfigFiles) {
expect(config.validate(path.join(__dirname, testConfigFile))).to.be.true;
expect(config.validate(path.join(__dirname, fixtures, testConfigFile))).to
.be.true;
}
});

Expand All @@ -134,7 +137,7 @@ describe('validate config files', function () {
];
for (const testConfigFile of invalidConfigFiles) {
const test = function () {
config.validate(path.join(__dirname, testConfigFile));
config.validate(path.join(__dirname, fixtures, testConfigFile));
};
expect(test).to.throw();
}
Expand Down

0 comments on commit f9c456d

Please sign in to comment.