From 1a1d83f51fda0df73776dda3ed1949613c72e04a Mon Sep 17 00:00:00 2001 From: Kevin Van Lierde Date: Tue, 15 Feb 2022 23:15:16 +0100 Subject: [PATCH] feat: use metalsmith.match instead of multimatch, drop Node < 10 support --- README.md | 2 +- lib/index.js | 10 ++++++++-- package-lock.json | 38 ++++++++------------------------------ package.json | 8 +++++--- 4 files changed, 22 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 2bbd0b9..3991a27 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Only files that match this pattern will be processed. So this `metalsmith.json`: ``` Would only process files within the `./src/blog` folder, because the pattern is -relative to your source folder. See [multimatch](https://github.com/sindresorhus/multimatch) +relative to your source folder. See [Metalsmith#match](https://metalsmith.io/api/#Metalsmith+match) for further details. ### `engineOptions` diff --git a/lib/index.js b/lib/index.js index f2f480f..d001359 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,5 @@ const path = require('path') const debug = require('debug')('@metalsmith/in-place') -const match = require('multimatch') const isUtf8 = require('is-utf8') const getTransformer = require('./get-transformer') @@ -125,7 +124,14 @@ module.exports = (options) => ) } - const matchedFiles = match(Object.keys(files), settings.pattern) + // throw update error in case users didn't see the peerDependency warning + if (!metalsmith.match) { + throw new Error( + 'This version of @metalsmith/in-place requires metalsmith^2.4.1\'s newly added match method\nPlease update metalsmith"' + ) + } + + const matchedFiles = metalsmith.match(settings.pattern) // Filter files by validity const validFiles = matchedFiles.filter((filename) => validate({ filename, files })) diff --git a/package-lock.json b/package-lock.json index ffa895c..b2b6c2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -655,11 +655,6 @@ "@types/node": "*" } }, - "@types/minimatch": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", - "integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==" - }, "@types/node": { "version": "17.0.18", "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.18.tgz", @@ -829,11 +824,6 @@ "sprintf-js": "~1.0.2" } }, - "array-differ": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/array-differ/-/array-differ-3.0.0.tgz", - "integrity": "sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==" - }, "array-includes": { "version": "3.1.4", "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.4.tgz", @@ -850,7 +840,8 @@ "array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", - "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==" + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true }, "array.prototype.flat": { "version": "1.2.5", @@ -863,11 +854,6 @@ "es-abstract": "^1.19.0" } }, - "arrify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz", - "integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==" - }, "asap": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", @@ -938,7 +924,8 @@ "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true }, "base64-js": { "version": "1.5.1", @@ -1089,6 +1076,7 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1486,7 +1474,8 @@ "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true }, "configstore": { "version": "5.0.1", @@ -3946,6 +3935,7 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, "requires": { "brace-expansion": "^1.1.7" } @@ -4150,18 +4140,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, - "multimatch": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/multimatch/-/multimatch-4.0.0.tgz", - "integrity": "sha512-lDmx79y1z6i7RNx0ZGCPq1bzJ6ZoDDKbvh7jxr9SJcWLkShMzXrHbYVpTdnhNM5MXpDUxCQ4DgqVttVXlBgiBQ==", - "requires": { - "@types/minimatch": "^3.0.3", - "array-differ": "^3.0.0", - "array-union": "^2.1.0", - "arrify": "^2.0.1", - "minimatch": "^3.0.4" - } - }, "mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", diff --git a/package.json b/package.json index ca01e5b..10c4320 100644 --- a/package.json +++ b/package.json @@ -50,11 +50,10 @@ "debug": "^4.0.0", "inputformat-to-jstransformer": "^1.2.1", "is-utf8": "^0.2.1", - "jstransformer": "^1.0.0", - "multimatch": "^4.0.0" + "jstransformer": "^1.0.0" }, "peerDependencies": { - "metalsmith": "^2.3.0" + "metalsmith": "^2.4.1" }, "publishConfig": { "access": "public" @@ -66,5 +65,8 @@ "directories": { "lib": "lib", "test": "test" + }, + "engines": { + "node": ">=10" } }