Skip to content

Commit 464929e

Browse files
authored
Merge pull request #1124 from jescalada/default-config-validation-error-fix
fix: default config validation error and extras
2 parents 8e38bd7 + 9305165 commit 464929e

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env tsx
22
/* eslint-disable max-len */
3+
import path from 'path';
34
import yargs from 'yargs';
45
import { hideBin } from 'yargs/helpers';
56
import * as fs from 'fs';
@@ -19,7 +20,7 @@ const argv = yargs(hideBin(process.argv))
1920
},
2021
config: {
2122
description: 'Path to custom git-proxy configuration file.',
22-
default: 'proxy.config.json',
23+
default: path.join(__dirname, 'proxy.config.json'),
2324
required: false,
2425
alias: 'c',
2526
type: 'string',

package-lock.json

Lines changed: 14 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config/file.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { readFileSync } from 'fs';
22
import { join } from 'path';
33
import { validate as jsonSchemaValidate } from 'jsonschema';
44

5-
export let configFile: string = join(process.cwd(), 'proxy.config.json');
5+
export let configFile: string = join(__dirname, '../../proxy.config.json');
66

77
/**
88
* Set the config file path.
@@ -20,7 +20,7 @@ export function setConfigFile(file: string) {
2020
*/
2121
export function validate(configFilePath: string = configFile!): boolean {
2222
const config = JSON.parse(readFileSync(configFilePath, 'utf-8'));
23-
const schemaPath = join(process.cwd(), 'config.schema.json');
23+
const schemaPath = join(__dirname, '../../config.schema.json');
2424
const schema = JSON.parse(readFileSync(schemaPath, 'utf-8'));
2525
jsonSchemaValidate(config, schema, { required: true, throwError: true });
2626
return true;

src/config/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,7 @@ export const getAPIAuthMethods = (): Authentication[] => {
126126
_apiAuthentication = _userSettings.apiAuthentication;
127127
}
128128

129-
const enabledAuthMethods = _apiAuthentication.filter((auth) => auth.enabled);
130-
131-
if (enabledAuthMethods.length === 0) {
132-
console.log('Warning: No authentication method enabled for API endpoints.');
133-
}
134-
135-
return enabledAuthMethods;
129+
return _apiAuthentication.filter((auth) => auth.enabled);
136130
};
137131

138132
// Log configuration to console

0 commit comments

Comments
 (0)