From dae1c2c602ac23f138c1c336949871ef384c6029 Mon Sep 17 00:00:00 2001 From: Nikola Hristov Date: Sat, 14 Oct 2023 15:30:02 +0300 Subject: [PATCH] squash! --- Source/Function/Integration.ts | 49 ++++++++++++++++++++++++++++++++++ Source/Index.ts | 46 ------------------------------- Source/Interface/Option.ts | 6 +++++ Source/Option/Index.ts | 12 --------- Source/Variable/Option.ts | 9 +++++++ 5 files changed, 64 insertions(+), 58 deletions(-) create mode 100644 Source/Function/Integration.ts delete mode 100644 Source/Index.ts create mode 100644 Source/Interface/Option.ts delete mode 100644 Source/Option/Index.ts create mode 100644 Source/Variable/Option.ts diff --git a/Source/Function/Integration.ts b/Source/Function/Integration.ts new file mode 100644 index 0000000..12a6f9f --- /dev/null +++ b/Source/Function/Integration.ts @@ -0,0 +1,49 @@ +/** + * @module Integration + * + */ +export default (_Option: Option = {}): AstroIntegration => { + for (const Option in _Option) { + if ( + Object.prototype.hasOwnProperty.call(_Option, Option) && + _Option[Option] === true + ) { + _Option[Option] = Default[Option as keyof typeof Default]; + } + } + + const { Path } = Merge(Default, _Option); + + const Paths = new Set(); + + if (typeof Path !== "undefined") { + if (Array.isArray(Path) || Path instanceof Set) { + for (const _Path of Path) { + Paths.add(_Path); + } + } + } + + return { + name: "astro-dead-links", + hooks: { + "astro:build:done": async ({ dir }) => { + if (!Paths.size) { + Paths.add(dir); + } + }, + }, + }; +}; + +import type Option from "../Interface/Option.js"; + +import type Path from "files-pipe/Target/Interface/Path.js"; + +import type { AstroIntegration } from "astro"; + +export const { default: Default } = await import("../Variable/Option.js"); + +export const { default: Merge } = await import( + "typescript-esbuild/Target/Function/Merge.js" +); diff --git a/Source/Index.ts b/Source/Index.ts deleted file mode 100644 index 5c0fb85..0000000 --- a/Source/Index.ts +++ /dev/null @@ -1,46 +0,0 @@ -import type { Option } from "./Option/Index.js"; - -import type { Path } from "files-pipe"; - -import type { AstroIntegration } from "astro"; - -import Default from "./Option/Index.js"; - -import { Merge } from "files-pipe"; - -export default (Options: Option = {}): AstroIntegration => { - for (const Option in Options) { - if ( - Object.prototype.hasOwnProperty.call(Options, Option) && - Options[Option] === true - ) { - Options[Option] = Default[Option]; - } - } - - const _options = Merge(Default, Options); - - const paths = new Set(); - - if (typeof _options["path"] !== "undefined") { - if ( - Array.isArray(_options["path"]) || - _options["path"] instanceof Set - ) { - for (const path of _options["path"]) { - paths.add(path); - } - } - } - - return { - name: "astro-dead-links", - hooks: { - "astro:build:done": async ({ dir }) => { - if (!paths.size) { - paths.add(dir); - } - }, - }, - }; -}; diff --git a/Source/Interface/Option.ts b/Source/Interface/Option.ts new file mode 100644 index 0000000..cf11607 --- /dev/null +++ b/Source/Interface/Option.ts @@ -0,0 +1,6 @@ +import type Option from "files-pipe/Target/Interface/Option.js"; + +export default interface Type extends Option { + // biome-ignore lint/suspicious/noExplicitAny: + [key: string]: any; +} diff --git a/Source/Option/Index.ts b/Source/Option/Index.ts deleted file mode 100644 index 7ea3ed7..0000000 --- a/Source/Option/Index.ts +++ /dev/null @@ -1,12 +0,0 @@ -import type { Option as _Option } from "files-pipe"; - -import { Default, Merge } from "files-pipe"; - -export default interface Option extends _Option { - // biome-ignore lint/suspicious/noExplicitAny: - [key: string]: any; -} - -export default Merge(Default, { - Action: {}, -} satisfies Option); diff --git a/Source/Variable/Option.ts b/Source/Variable/Option.ts new file mode 100644 index 0000000..7a17647 --- /dev/null +++ b/Source/Variable/Option.ts @@ -0,0 +1,9 @@ +/** + * @module Option + * + */ +export default ( + await import("typescript-esbuild/Target/Function/Merge.js") +).default((await import("files-pipe/Target/Variable/Option.js")).default, { + Action: {}, +});