Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: semantic release prepare lifecycle arguments #39

Merged
merged 1 commit into from
Sep 25, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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