generated from insurgent-lab/javascript-lib-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace placeholder content with plugin API
- Loading branch information
Showing
3 changed files
with
27 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
/** | ||
* Sums up two numbers. | ||
* | ||
* @param {number} a The first number to add. | ||
* @param {number} b The second number to add. | ||
* @returns {number} The resulting sum of the two numbers. | ||
* Called by semantic-release during the verification step | ||
* | ||
* @param {*} pluginConfig The semantic-release plugin config | ||
* @param {*} context The context provided by semantic-release | ||
*/ | ||
export declare function add(a: number, b: number): number | ||
export declare function verifyConditions(pluginConfig: any, context: any): void | ||
|
||
/** | ||
* Sums up a list of numbers. | ||
* | ||
* @param {number[]} numbers An array of numbers to add. | ||
* @returns {number} The resulting sum of all the numbers. | ||
* Called by semantic-release during the prepare step | ||
* | ||
* @param {*} pluginConfig The semantic-release plugin config | ||
* @param {*} context The context provided by semantic-release | ||
*/ | ||
export declare function add(numbers: number[]): number | ||
export declare function prepare(pluginConfig: any, context: any): void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
export function add(a, b) { | ||
if (Array.isArray(a)) { | ||
return a.reduce((sum, val) => sum + val, 0); | ||
} else if ( | ||
arguments.length === 2 && | ||
typeof a === "number" && | ||
typeof b === "number" | ||
) { | ||
return a + b; | ||
} | ||
/* eslint-disable no-unused-vars */ | ||
|
||
throw new Error("Invalid input"); | ||
let verified; | ||
let prepared; | ||
|
||
export async function verifyConditions(pluginConfig, context) { | ||
verified = true; | ||
} | ||
|
||
export async function prepare(pluginConfig, context) { | ||
prepared = true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,13 @@ | ||
import { add } from "../lib/index"; | ||
import { prepare, verifyConditions } from "../lib/index"; | ||
|
||
describe("add", () => { | ||
describe("verifyConditions", () => { | ||
it("should be defined", () => { | ||
expect(add).toBeDefined(); | ||
}); | ||
|
||
it("should sum up two numbers", () => { | ||
expect(add(42, 42)).toBe(84); | ||
}); | ||
|
||
it("should sum up a list of numbers", () => { | ||
expect(add([42, 42])).toBe(84); | ||
expect(verifyConditions).toBeDefined(); | ||
}); | ||
}); | ||
|
||
it("should throw for invalid inputs", () => { | ||
expect(() => add()).toThrow("Invalid input"); | ||
expect(() => add(42)).toThrow("Invalid input"); | ||
describe("prepare", () => { | ||
it("should be defined", () => { | ||
expect(prepare).toBeDefined(); | ||
}); | ||
}); |