Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cwd, readConfig, readFile, writeFile } from "./utils/filesystem";
import { cwd, readFile, writeFile } from "./utils/filesystem";
import { context, getOctokit } from "@actions/github";
import { parse } from "./utils/inputs";
import { info } from "@actions/core";
Expand All @@ -8,6 +8,7 @@ import { setPreview } from "./utils/preview";
import { setOutputs } from "./utils/outputs";
import { getPackageManager } from "./utils/packageManagers";
import { titleCase } from "./utils/strings";
import { readConfig } from './utils/config'

const previewUpdater = async () => {
// Inputs
Expand Down
16 changes: 16 additions & 0 deletions src/utils/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Config, defaultConfig } from '../types/config'
import { deepmerge } from 'deepmerge-ts'
import * as yaml from 'js-yaml'
import { readFile } from './filesystem'

export const readConfig = (config: Config, userConfigPath: string): Config => {
const content: string = readFile(config, userConfigPath);

if (content === "") {
return <Config>deepmerge(defaultConfig, config);
}

const userConfig = <Config>yaml.load(content);

return <Config>deepmerge(defaultConfig, userConfig, config);
};
12 changes: 0 additions & 12 deletions src/utils/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@ export const writeFile = (
fs.writeFileSync(filePath(config, filename), content);
};

export const readConfig = (config: Config, userConfigPath: string): Config => {
const content: string = readFile(config, userConfigPath);

if (content === "") {
return <Config>deepmerge(defaultConfig, config);
}

const userConfig = <Config>yaml.load(content);

return <Config>deepmerge(defaultConfig, userConfig, config);
};

export const exec = async (command: string): Promise<string> => {
const execAsync = promisify(nodeExec);

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/filesystem.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { rawTestConfig } from "../helpers/config";
import { type Config, defaultConfig } from "../../src/types/config";
import { readConfig } from "../../src/utils/filesystem";
import { CONFIG_PATH } from "../../src/utils/inputs";
import { readConfig } from '../../src/utils/config'

test("read config", () => {
const data: Config = readConfig(rawTestConfig, CONFIG_PATH.defaultValue);
Expand Down
Loading