Skip to content

Commit

Permalink
feat: 🎸 allow undefined for PluginConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
suin committed Feb 9, 2022
1 parent b4872b2 commit 57dd862
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 11 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ let verified = false;
let prepared = false;
const yarn = new Yarn();

export type { PluginConfig };

export async function verifyConditions(
config: PluginConfig,
config: PluginConfig | undefined = undefined,
context: Context
): Promise<void> {
config = PluginConfig.normalize(config);
Expand All @@ -36,7 +38,10 @@ export async function verifyConditions(
verified = true;
}

export async function prepare(config: PluginConfig, context: PrepareContext) {
export async function prepare(
config: PluginConfig | undefined = undefined,
context: PrepareContext
) {
config = PluginConfig.normalize(config);
if (!verified) {
return;
Expand Down Expand Up @@ -70,7 +75,10 @@ export async function prepare(config: PluginConfig, context: PrepareContext) {
prepared = true;
}

export async function publish(config: PluginConfig, context: PrepareContext) {
export async function publish(
config: PluginConfig | undefined = undefined,
context: PrepareContext
) {
config = PluginConfig.normalize(config);
if (!verified || !prepared) {
return;
Expand Down
5 changes: 4 additions & 1 deletion pluginConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export interface PluginConfig {
}

export const PluginConfig = {
normalize({ npmPublish, tarballDir }: PluginConfig): PluginConfig {
normalize({
npmPublish,
tarballDir,
}: PluginConfig | undefined = {}): PluginConfig {
assertNullableBoolean(npmPublish, "npmPublish");
assertNullableString(tarballDir, "tarballDir");
return {
Expand Down

0 comments on commit 57dd862

Please sign in to comment.