From 8950b05817770599122facedd377c63fd7bf1919 Mon Sep 17 00:00:00 2001 From: Kevin Van Lierde Date: Wed, 30 Nov 2022 02:18:01 +0100 Subject: [PATCH] Enhanced types and rename default export to 'remove' --- .gitignore | 2 +- lib/index.d.ts | 18 ++++++++++++++++++ package.json | 2 +- src/index.js | 4 ++-- 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 lib/index.d.ts diff --git a/.gitignore b/.gitignore index a3e138e..248656f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ coverage.info .nyc_output # build output -lib \ No newline at end of file +lib/*.*js \ No newline at end of file diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 0000000..e9633b4 --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,18 @@ +import { Plugin } from 'metalsmith'; + +export default remove; +export type Options = { + patterns: string[]; +}; +/** + * + * @typedef {Object} Options + * @property {String[]} patterns + */ +/** + * A Metalsmith plugin to remove files from the build + * + * @param {String|String[]|Options} [options] One or more [glob patterns](https://en.wikipedia.org/wiki/Glob_(programming)) + * @return {import('metalsmith').Plugin} + */ +declare function remove(options?: string | string[] | Options): Plugin; diff --git a/package.json b/package.json index 8d839e7..a438430 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.2.1", "description": "A Metalsmith plugin to remove files from the build", "keywords": [ - "ignore", + "remove", "metalsmith-plugin", "metalsmith" ], diff --git a/src/index.js b/src/index.js index 27c66c2..3b6f500 100644 --- a/src/index.js +++ b/src/index.js @@ -13,7 +13,7 @@ const debug = debugLib('@metalsmith/remove') * @param {String|String[]|Options} [options] One or more [glob patterns](https://en.wikipedia.org/wiki/Glob_(programming)) * @return {import('metalsmith').Plugin} */ -function initRemove(options) { +function remove(options) { return function remove(files, metalsmith, done) { if ('string' == typeof options) { options = [options] @@ -36,4 +36,4 @@ function initRemove(options) { } } -export default initRemove +export default remove