From d779d1be0564f9951e37e705b8083d316a15cf94 Mon Sep 17 00:00:00 2001 From: Justin Eveland Date: Fri, 17 Feb 2023 14:19:12 -0500 Subject: [PATCH] fix: sync updates from upstream repolinter --- __tests__/getConfig.test.ts | 4 ++-- src/createorUpdateIssue.ts | 3 +-- src/getConfig.ts | 10 +++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/__tests__/getConfig.test.ts b/__tests__/getConfig.test.ts index 93d69a2..c081e3e 100644 --- a/__tests__/getConfig.test.ts +++ b/__tests__/getConfig.test.ts @@ -21,7 +21,7 @@ describe('getConfig', () => { test('getConfig returns a config from a YAML', async () => { const filepath = path.resolve(__dirname, 'testconfig.yaml') - const expected = yaml.safeLoad( + const expected = yaml.load( await fs.promises.readFile(filepath, 'utf8') ) as Record const res = await getConfig({configFile: filepath}) @@ -53,7 +53,7 @@ describe('getConfig', () => { const url = 'https://raw.githubusercontent.com/aperture-science-incorporated/.github/master/repolinter.yaml' const filepath = path.resolve(__dirname, 'testconfig.yaml') - const expected = yaml.safeLoad( + const expected = yaml.load( await fs.promises.readFile(filepath, 'utf8') ) as Record const scope = nock('https://raw.githubusercontent.com') diff --git a/src/createorUpdateIssue.ts b/src/createorUpdateIssue.ts index 97a6a6c..88c22a8 100644 --- a/src/createorUpdateIssue.ts +++ b/src/createorUpdateIssue.ts @@ -279,8 +279,7 @@ export interface UpdateReplolinterIssueOpts { * @param options.owner The owner of the repository to update the issue on * @param options.repo The name of the repository to update the issue on * @param options.issueNumber The issue number to update (ex. #2, different from the ID) - * @param options.issueContent The body to update the issue with, formatted as - * markdown. + * @param options.issueContent The body to update the issue with, formatted as markdown. * @param options.shouldClose Set this to true to close the issue, otherwise the issue * @param options.runNumber The current GITHUB_RUN_NUMBER, which will be * inserted at the bottom of the issue. diff --git a/src/getConfig.ts b/src/getConfig.ts index 0e7856c..c14c821 100644 --- a/src/getConfig.ts +++ b/src/getConfig.ts @@ -9,12 +9,12 @@ import {validateConfig} from 'repolinter' * validated deserialized configuration. * * @param where.configFile The file path to the config, relative to the current - * working directory. Mutually exclusive with where.configUrl. + * working directory. Mutually exclusive with where.configUrl. * @param where.configUrl The URL to load fhe config from. Mutually exclusive - * with where.configFile + * with where.configFile * @returns A deserialized JSON or YAML configuration object if one was found. - * If the configuration does not exist or does not pass validation this - * function will throw an error. + * If the configuration does not exist or does not pass validation this + * function will throw an error. */ export default async function getConfig(where: { configFile?: string @@ -65,7 +65,7 @@ export default async function getConfig(where: { } if (!ret) { try { - ret = yaml.safeLoad(contents) + ret = yaml.load(contents, {schema: yaml.JSON_SCHEMA}) } catch (e) { yamlError = e }