Skip to content

Commit

Permalink
fix: semantic release prepare lifecycle arguments (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeshuaro committed Sep 25, 2023
1 parent 8013c3e commit 2bf9915
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .eslintrc.json
Expand Up @@ -11,7 +11,12 @@
"rules": {
"no-unused-vars": [
"error",
{ "vars": "all", "args": "all", "ignoreRestSiblings": false }
{
"vars": "all",
"args": "all",
"ignoreRestSiblings": false,
"argsIgnorePattern": "^_"
}
]
}
}
9 changes: 5 additions & 4 deletions src/prepare.ts
Expand Up @@ -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));

Expand Down
7 changes: 5 additions & 2 deletions tests/prepare.test.ts
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 2bf9915

Please sign in to comment.