Skip to content

Commit

Permalink
feat-fix(config): load support for absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
EagleoutIce committed Jan 22, 2025
1 parent d4f6519 commit 7d5af29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cli/flowr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { defaultConfigFile, flowrMainOptionDefinitions, getScriptsText } from '.
import { TreeSitterExecutor } from '../r-bridge/lang-4.x/tree-sitter/tree-sitter-executor';
import type { KnownParser } from '../r-bridge/parser';
import fs from 'fs';
import path from 'path';

export const toolName = 'flowr';

Expand Down Expand Up @@ -98,7 +99,7 @@ if(options['config-json']) {
if(!usedConfig) {
if(options['config-file']) {
// validate it exists
if(!fs.existsSync(options['config-file'])) {
if(!fs.existsSync(path.resolve(options['config-file']))) {
log.error(`Config file '${options['config-file']}' does not exist`);
process.exit(1);
}
Expand Down
8 changes: 8 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ export function getEngineConfig<T extends EngineConfig['type']>(engine: T): Engi

function loadConfigFromFile(configFile: string | undefined, workingDirectory: string): FlowrConfigOptions {
if(configFile !== undefined) {
if(path.isAbsolute(configFile) && fs.existsSync(configFile)) {
log.trace(`Found config at ${configFile} (absolute)`);
const ret = parseConfig(fs.readFileSync(configFile, { encoding: 'utf-8' }));
if(ret) {
log.info(`Using config ${JSON.stringify(ret)}`);
return ret;
}
}
let searchPath = path.resolve(workingDirectory);
do{
const configPath = path.join(searchPath, configFile);
Expand Down

0 comments on commit 7d5af29

Please sign in to comment.