From 57dd862be7332aa9c22d397a7e1864f709f62e7a Mon Sep 17 00:00:00 2001 From: suin Date: Thu, 10 Feb 2022 05:26:53 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20allow=20undefined=20for?= =?UTF-8?q?=20PluginConfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.ts | 14 +++++++++++--- pluginConfig.ts | 5 ++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index 9e3a3cd..7619dca 100644 --- a/index.ts +++ b/index.ts @@ -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 { config = PluginConfig.normalize(config); @@ -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; @@ -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; diff --git a/pluginConfig.ts b/pluginConfig.ts index 38f6ef8..5febb56 100644 --- a/pluginConfig.ts +++ b/pluginConfig.ts @@ -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 {