mem-fs-editor
Advanced tools
Comparing version 9.1.0 to 9.2.0
@@ -35,3 +35,7 @@ 'use strict'; | ||
module.exports = async function (file) { | ||
this.store.add(file); | ||
const existingFile = this.store.get(file.path); | ||
if (!existingFile || existingFile !== file) { | ||
this.store.add(file); | ||
} | ||
if (isFileStateModified(file)) { | ||
@@ -38,0 +42,0 @@ setCommittedFile(file); |
'use strict'; | ||
const assert = require('assert'); | ||
const {setModifiedFileState} = require('../state'); | ||
const {isFileStateModified, setModifiedFileState} = require('../state'); | ||
@@ -13,8 +13,16 @@ module.exports = function (filepath, contents, stat) { | ||
const file = this.store.get(filepath); | ||
setModifiedFileState(file); | ||
file.contents = Buffer.isBuffer(contents) ? contents : Buffer.from(contents); | ||
file.stat = stat; | ||
this.store.add(file); | ||
const newContents = Buffer.isBuffer(contents) ? contents : Buffer.from(contents); | ||
if ( | ||
!isFileStateModified(file) | ||
|| !Buffer.isBuffer(file.contents) | ||
|| !newContents.equals(file.contents) | ||
|| (stat !== undefined && file.stat !== stat) | ||
) { | ||
setModifiedFileState(file); | ||
file.contents = newContents; | ||
file.stat = stat; | ||
this.store.add(file); | ||
} | ||
return file.contents.toString(); | ||
}; |
{ | ||
"name": "mem-fs-editor", | ||
"version": "9.1.0", | ||
"version": "9.2.0", | ||
"description": "File edition helpers working on top of mem-fs", | ||
@@ -18,3 +18,3 @@ "scripts": { | ||
"dependencies": { | ||
"binaryextensions": "^4.15.0", | ||
"binaryextensions": "^4.16.0", | ||
"commondir": "^1.0.1", | ||
@@ -27,3 +27,3 @@ "deep-extend": "^0.6.0", | ||
"normalize-path": "^3.0.0", | ||
"textextensions": "^5.12.0" | ||
"textextensions": "^5.13.0" | ||
}, | ||
@@ -42,3 +42,3 @@ "peerDependencies": { | ||
"eslint": "^7.26.0", | ||
"eslint-config-xo-space": "^0.28.0", | ||
"eslint-config-xo-space": "^0.29.0", | ||
"jest": "^27.0.6", | ||
@@ -45,0 +45,0 @@ "mem-fs": "^2.2.1", |
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
29454
609
Updatedbinaryextensions@^4.16.0
Updatedtextextensions@^5.13.0