Skip to content

Commit 717afde

Browse files
committed
fix: config validation error on load from build
1 parent d4d9239 commit 717afde

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
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',

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;

0 commit comments

Comments
 (0)