mem-fs-editor
Advanced tools
Comparing version 9.6.0 to 9.7.0
@@ -8,2 +8,3 @@ 'use strict'; | ||
const { createPendingFilesPassthrough, createCommitTransform } = require('../transform'); | ||
const { isFilePending } = require('../state'); | ||
@@ -20,3 +21,3 @@ module.exports = function (filters, stream, cb) { | ||
stream = stream || this.store.stream(); | ||
stream = stream || this.store.stream({ filter: (file) => isFilePending(file) }); | ||
filters = filters || []; | ||
@@ -23,0 +24,0 @@ |
@@ -9,9 +9,8 @@ 'use strict'; | ||
module.exports = function ( | ||
cwd = process.cwd(), | ||
filter = (file) => hasClearedState(file) || hasState(file) | ||
) { | ||
const defaultDumpFilter = (file) => hasClearedState(file) || hasState(file); | ||
module.exports = function (cwd = process.cwd(), filter = defaultDumpFilter) { | ||
if (typeof filter === 'string') { | ||
const pattern = filter; | ||
filter = (file) => minimatch(file.path, pattern); | ||
filter = (file) => defaultDumpFilter(file) && minimatch(file.path, pattern); | ||
} | ||
@@ -18,0 +17,0 @@ |
@@ -46,2 +46,19 @@ const fs = require('fs'); | ||
/** | ||
* Delete commit related states. | ||
*/ | ||
const resetFileCommitStates = (file) => { | ||
delete file[STATE_CLEARED]; | ||
delete file.committed; | ||
}; | ||
/** | ||
* Delete all mem-fs-editor`s related states. | ||
*/ | ||
const resetFile = (file) => { | ||
resetFileState(file); | ||
resetFileCommitStates(file); | ||
delete file[IS_NEW]; | ||
}; | ||
const clearFileState = (file) => { | ||
@@ -74,2 +91,4 @@ if (file[STATE]) { | ||
resetFileState, | ||
resetFileCommitStates, | ||
resetFile, | ||
clearFileState, | ||
@@ -76,0 +95,0 @@ hasState, |
{ | ||
"name": "mem-fs-editor", | ||
"version": "9.6.0", | ||
"version": "9.7.0", | ||
"description": "File edition helpers working on top of mem-fs", | ||
@@ -23,4 +23,4 @@ "scripts": { | ||
"globby": "^11.1.0", | ||
"isbinaryfile": "^4.0.8", | ||
"minimatch": "^3.1.2", | ||
"isbinaryfile": "^5.0.0", | ||
"minimatch": "^7.2.0", | ||
"multimatch": "^5.0.0", | ||
@@ -43,8 +43,8 @@ "normalize-path": "^3.0.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-config-xo": "^0.39.0", | ||
"eslint-config-xo": "^0.43.1", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"jest": "^27.0.6", | ||
"mem-fs": "^2.2.1", | ||
"jest": "^29.4.3", | ||
"mem-fs": "^2.3.0", | ||
"prettier": "^2.5.1", | ||
"sinon": "^12.0.1" | ||
"sinon": "^15.0.1" | ||
}, | ||
@@ -51,0 +51,0 @@ "jest": { |
@@ -155,2 +155,3 @@ # mem-fs-editor | ||
Provide a `cwd` for relative path. Allows to omit temporary path. | ||
Provide a `filter` function or glob to focus on specific files. | ||
Provide a `filter` function or a pattern to focus on specific files. | ||
`dump` returns only modified (committed or not) files when no filter or a pattern is provided. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31777
700
157
+ Addedisbinaryfile@5.0.2(transitive)
+ Addedminimatch@7.4.6(transitive)
- Removedisbinaryfile@4.0.10(transitive)
Updatedisbinaryfile@^5.0.0
Updatedminimatch@^7.2.0