Skip to content

Commit

Permalink
feat: use metalsmith.match instead of multimatch, drop Node < 10 support
Browse files Browse the repository at this point in the history
  • Loading branch information
webketje committed Feb 15, 2022
1 parent ce3c8f1 commit 1a1d83f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
10 changes: 8 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -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')

Expand Down Expand Up @@ -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 }))
Expand Down
38 changes: 8 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -66,5 +65,8 @@
"directories": {
"lib": "lib",
"test": "test"
},
"engines": {
"node": ">=10"
}
}

0 comments on commit 1a1d83f

Please sign in to comment.