From 2bf9915ce8fb23bd8480e6744a636c0bc80721bd Mon Sep 17 00:00:00 2001 From: Joshua Tang Date: Tue, 26 Sep 2023 00:38:53 +1000 Subject: [PATCH] fix: semantic release `prepare` lifecycle arguments (#39) --- .eslintrc.json | 7 ++++++- src/prepare.ts | 9 +++++---- tests/prepare.test.ts | 7 +++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 8632f0c..bd8a367 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,7 +11,12 @@ "rules": { "no-unused-vars": [ "error", - { "vars": "all", "args": "all", "ignoreRestSiblings": false } + { + "vars": "all", + "args": "all", + "ignoreRestSiblings": false, + "argsIgnorePattern": "^_" + } ] } } diff --git a/src/prepare.ts b/src/prepare.ts index 4e2eeab..ffb1109 100644 --- a/src/prepare.ts +++ b/src/prepare.ts @@ -2,13 +2,14 @@ import { readFileSync, writeFileSync } from 'fs'; import { PrepareContext } from 'semantic-release'; import { parse } from 'yaml'; import { Pubspec } from './schemas.js'; +import { PluginConfig } from './types.js'; const PUBSPEC_PATH = 'pubspec.yaml'; -export const prepare = async ({ - nextRelease: { version }, - logger -}: PrepareContext) => { +export const prepare = async ( + _pluginConfig: PluginConfig, + { nextRelease: { version }, logger }: PrepareContext +) => { const data = readFileSync(PUBSPEC_PATH, 'utf-8'); const pubspec = Pubspec.parse(parse(data)); diff --git a/tests/prepare.test.ts b/tests/prepare.test.ts index 677df9e..7cc655a 100644 --- a/tests/prepare.test.ts +++ b/tests/prepare.test.ts @@ -4,13 +4,16 @@ import { NextRelease, PrepareContext } from 'semantic-release'; import { Signale } from 'signale'; import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'; import { mock } from 'vitest-mock-extended'; -import { prepare } from '../src/index.js'; +import { PluginConfig, prepare } from '../src/index.js'; vi.mock('fs'); describe('prepare', () => { const newVersion = '1.2.3'; const pubspecPath = 'pubspec.yaml'; + const cli = 'dart'; + + const config: PluginConfig = { cli, publishPub: true }; const oldPubspec = codeBlock` name: pub_package @@ -57,7 +60,7 @@ describe('prepare', () => { test('success', async () => { vi.mocked(readFileSync).mockReturnValue(oldPubspec); - await prepare(context); + await prepare(config, context); expect(readFileSync).toHaveBeenNthCalledWith(1, pubspecPath, 'utf-8'); expect(writeFileSync).toHaveBeenNthCalledWith(1, pubspecPath, newPubspec);