Update to 5.4.1 for fix nodejs upgrade
(cherry picked from commit a1522cff909faffdf8181ca560f1f213e06e4748)
This commit is contained in:
parent
4e258dbaab
commit
bdf5a409d0
@ -1,74 +0,0 @@
|
|||||||
From aed119a2d2d5c9b1fba7ad2ca652d9198f1af5ca Mon Sep 17 00:00:00 2001
|
|
||||||
From: wang__ge <wang__ge@126.com>
|
|
||||||
Date: Mon, 6 May 2024 11:17:28 +0800
|
|
||||||
Subject: [PATCH] create mock file before write
|
|
||||||
|
|
||||||
---
|
|
||||||
test/lib/fs.appendFile.spec.js | 4 ++--
|
|
||||||
test/lib/fs.createWriteStream.spec.js | 2 +-
|
|
||||||
test/lib/fs.writeFile.spec.js | 2 +-
|
|
||||||
test/lib/index.spec.js | 2 +-
|
|
||||||
4 files changed, 5 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/test/lib/fs.appendFile.spec.js b/test/lib/fs.appendFile.spec.js
|
|
||||||
index 72751c4..93d3ba8 100644
|
|
||||||
--- a/test/lib/fs.appendFile.spec.js
|
|
||||||
+++ b/test/lib/fs.appendFile.spec.js
|
|
||||||
@@ -118,12 +118,12 @@ describe('fs.appendFileSync(filename, data, [options]', function () {
|
|
||||||
afterEach(mock.restore);
|
|
||||||
|
|
||||||
it('writes a string to a new file', function () {
|
|
||||||
- fs.appendFileSync('foo', 'bar');
|
|
||||||
+ mock({'foo': 'bar'});
|
|
||||||
assert.equal(String(fs.readFileSync('foo')), 'bar');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('appends a string to an existing file', function () {
|
|
||||||
- fs.appendFileSync('path/to/file', ' bar');
|
|
||||||
+ mock({'path/to/file': 'content bar'});
|
|
||||||
assert.equal(String(fs.readFileSync('path/to/file')), 'content bar');
|
|
||||||
});
|
|
||||||
|
|
||||||
diff --git a/test/lib/fs.createWriteStream.spec.js b/test/lib/fs.createWriteStream.spec.js
|
|
||||||
index 6aba06f..7f30710 100644
|
|
||||||
--- a/test/lib/fs.createWriteStream.spec.js
|
|
||||||
+++ b/test/lib/fs.createWriteStream.spec.js
|
|
||||||
@@ -77,8 +77,8 @@ describe('fs.createWriteStream(path[, options])', function () {
|
|
||||||
output.write(Buffer.from('lots '));
|
|
||||||
output.write(Buffer.from('of '));
|
|
||||||
output.write(Buffer.from('source '));
|
|
||||||
- output.end(Buffer.from('content'));
|
|
||||||
output.uncork();
|
|
||||||
+ output.end(Buffer.from('content'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
diff --git a/test/lib/fs.writeFile.spec.js b/test/lib/fs.writeFile.spec.js
|
|
||||||
index bf73f4f..9e16768 100644
|
|
||||||
--- a/test/lib/fs.writeFile.spec.js
|
|
||||||
+++ b/test/lib/fs.writeFile.spec.js
|
|
||||||
@@ -102,7 +102,7 @@ describe('fs.writeFileSync(filename, data, [options]', function () {
|
|
||||||
afterEach(mock.restore);
|
|
||||||
|
|
||||||
it('writes a string to a file', function () {
|
|
||||||
- fs.writeFileSync('foo', 'bar');
|
|
||||||
+ mock({foo: 'bar'});
|
|
||||||
assert.equal(String(fs.readFileSync('foo')), 'bar');
|
|
||||||
});
|
|
||||||
|
|
||||||
diff --git a/test/lib/index.spec.js b/test/lib/index.spec.js
|
|
||||||
index 65d2314..e4b5f94 100644
|
|
||||||
--- a/test/lib/index.spec.js
|
|
||||||
+++ b/test/lib/index.spec.js
|
|
||||||
@@ -547,7 +547,7 @@ if (process.getuid && process.getgid) {
|
|
||||||
err = e;
|
|
||||||
}
|
|
||||||
assert.instanceOf(err, Error);
|
|
||||||
- assert.equal(err.code, 'EACCES');
|
|
||||||
+ assert.equal(err.code, 'ENOENT');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.43.0
|
|
||||||
|
|
||||||
@ -1,231 +0,0 @@
|
|||||||
From 639b6392b99dfb4cde8bdf3ee621f03ce851fd31 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Andrew Nicols <andrew@nicols.co.uk>
|
|
||||||
Date: Sat, 14 Oct 2023 00:47:14 +0800
|
|
||||||
Subject: [PATCH] Mock sync methods to support v20.8
|
|
||||||
|
|
||||||
---
|
|
||||||
lib/binding.js | 141 ++++++++++++++++++++++++++++++++++++++++
|
|
||||||
test/lib/bypass.spec.js | 2 +-
|
|
||||||
2 files changed, 142 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/lib/binding.js b/lib/binding.js
|
|
||||||
index a4a3e6c..e9db26b 100644
|
|
||||||
--- a/lib/binding.js
|
|
||||||
+++ b/lib/binding.js
|
|
||||||
@@ -306,6 +306,17 @@ Binding.prototype.stat = function (filepath, bigint, callback, ctx) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
+/**
|
|
||||||
+ * Stat an item.
|
|
||||||
+ * @param {string} filepath Path.
|
|
||||||
+ * @param {boolean} bigint Use BigInt.
|
|
||||||
+ * @param {object} ctx Context object (optional), only for nodejs v10+.
|
|
||||||
+ * @return {Float64Array|BigUint64Array|undefined} Stats or undefined if sync.
|
|
||||||
+ */
|
|
||||||
+Binding.prototype.statSync = function (filepath, bigint, ctx) {
|
|
||||||
+ return this.stat(filepath, bigint, undefined, ctx);
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Stat an item.
|
|
||||||
* @param {number} fd File descriptor.
|
|
||||||
@@ -341,6 +352,16 @@ Binding.prototype.close = function (fd, callback, ctx) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
+/**
|
|
||||||
+ * Close a file descriptor.
|
|
||||||
+ * @param {number} fd File descriptor.
|
|
||||||
+ * @param {object} ctx Context object (optional), only for nodejs v10+.
|
|
||||||
+ * @return {*} The return.
|
|
||||||
+ */
|
|
||||||
+Binding.prototype.closeSync = function (fd, ctx) {
|
|
||||||
+ return this.close(fd, undefined, ctx);
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Open and possibly create a file.
|
|
||||||
* @param {string} pathname File path.
|
|
||||||
@@ -410,6 +431,18 @@ Binding.prototype.open = function (pathname, flags, mode, callback, ctx) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
+/**
|
|
||||||
+ * Open and possibly create a file.
|
|
||||||
+ * @param {string} pathname File path.
|
|
||||||
+ * @param {number} flags Flags.
|
|
||||||
+ * @param {number} mode Mode.
|
|
||||||
+ * @param {object} ctx Context object (optional), only for nodejs v10+.
|
|
||||||
+ * @return {string} File descriptor.
|
|
||||||
+ */
|
|
||||||
+Binding.prototype.openSync = function (pathname, flags, mode, ctx) {
|
|
||||||
+ return this.open(pathname, flags, mode, undefined, ctx);
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Open a file handler. A new api in nodejs v10+ for fs.promises
|
|
||||||
* @param {string} pathname File path.
|
|
||||||
@@ -531,6 +564,18 @@ Binding.prototype.copyFile = function (src, dest, flags, callback, ctx) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
+/**
|
|
||||||
+ * Write to a file descriptor given a buffer.
|
|
||||||
+ * @param {string} src Source file.
|
|
||||||
+ * @param {string} dest Destination file.
|
|
||||||
+ * @param {number} flags Modifiers for copy operation.
|
|
||||||
+ * @param {object} ctx Context object (optional), only for nodejs v10+.
|
|
||||||
+ * @return {*} The return if no callback is provided.
|
|
||||||
+ */
|
|
||||||
+Binding.prototype.copyFileSync = function (src, dest, flags, ctx) {
|
|
||||||
+ return this.copyFile(src, dest, flags, undefined, ctx);
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Write to a file descriptor given a buffer.
|
|
||||||
* @param {string} fd File descriptor.
|
|
||||||
@@ -722,6 +767,17 @@ Binding.prototype.rename = function (oldPath, newPath, callback, ctx) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
+/**
|
|
||||||
+ * Rename a file.
|
|
||||||
+ * @param {string} oldPath Old pathname.
|
|
||||||
+ * @param {string} newPath New pathname.
|
|
||||||
+ * @param {object} ctx Context object (optional), only for nodejs v10+.
|
|
||||||
+ * @return {undefined}
|
|
||||||
+ */
|
|
||||||
+Binding.prototype.renameSync = function (oldPath, newPath, ctx) {
|
|
||||||
+ return this.rename(oldPath, newPath, undefined, ctx);
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Read a directory.
|
|
||||||
* @param {string} dirpath Path to directory.
|
|
||||||
@@ -779,6 +835,24 @@ Binding.prototype.readdir = function (
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
+Binding.prototype.readFile = function (filepath, options, callback, ctx) {
|
|
||||||
+ markSyscall(ctx, 'readFile');
|
|
||||||
+
|
|
||||||
+ return maybeCallback(normalizeCallback(callback), ctx, this, function () {
|
|
||||||
+ filepath = deBuffer(filepath);
|
|
||||||
+ const item = this._system.getItem(filepath);
|
|
||||||
+
|
|
||||||
+ return item.getContent();
|
|
||||||
+ });
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+Binding.prototype.readFileSync = function (filepath, options, ctx) {
|
|
||||||
+ return this.readFile(filepath, options, undefined, ctx);
|
|
||||||
+};
|
|
||||||
+Binding.prototype.readFileUtf8 = function (filepath, options, ctx) {
|
|
||||||
+ return this.readFile(filepath, options, undefined, ctx).toString('utf-8');
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Create a directory.
|
|
||||||
* @param {string} pathname Path to new directory.
|
|
||||||
@@ -1059,6 +1133,16 @@ Binding.prototype.unlink = function (pathname, callback, ctx) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
+/**
|
|
||||||
+ * Delete a named item.
|
|
||||||
+ * @param {string} pathname Path to item.
|
|
||||||
+ * @param {object} ctx Context object (optional), only for nodejs v10+.
|
|
||||||
+ * @return {*} The return if no callback is provided.
|
|
||||||
+ */
|
|
||||||
+Binding.prototype.unlinkSync = function (pathname, ctx) {
|
|
||||||
+ return this.unlink(pathname, undefined, ctx);
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Update timestamps.
|
|
||||||
* @param {string} pathname Path to item.
|
|
||||||
@@ -1241,6 +1325,18 @@ Binding.prototype.symlink = function (srcPath, destPath, type, callback, ctx) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
+/**
|
|
||||||
+ * Create a symbolic link.
|
|
||||||
+ * @param {string} srcPath Path from link to the source file.
|
|
||||||
+ * @param {string} destPath Path for the generated link.
|
|
||||||
+ * @param {string} type Ignored (used for Windows only).
|
|
||||||
+ * @param {object} ctx Context object (optional), only for nodejs v10+.
|
|
||||||
+ * @return {*} The return if no callback is provided.
|
|
||||||
+ */
|
|
||||||
+Binding.prototype.symlinkSync = function (srcPath, destPath, type, ctx) {
|
|
||||||
+ return this.symlink(srcPath, destPath, type, undefined, ctx);
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Read the contents of a symbolic link.
|
|
||||||
* @param {string} pathname Path to symbolic link.
|
|
||||||
@@ -1338,6 +1434,51 @@ Binding.prototype.access = function (filepath, mode, callback, ctx) {
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
+/**
|
|
||||||
+ * Tests user permissions.
|
|
||||||
+ * @param {string} filepath Path.
|
|
||||||
+ * @param {number} mode Mode.
|
|
||||||
+ * @param {object} ctx Context object (optional), only for nodejs v10+.
|
|
||||||
+ * @return {*} The return if no callback is provided.
|
|
||||||
+ */
|
|
||||||
+Binding.prototype.accessSync = function (filepath, mode, ctx) {
|
|
||||||
+ return this.access(filepath, mode, undefined, ctx);
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * Tests whether or not the given path exists.
|
|
||||||
+ * @param {string} filepath Path.
|
|
||||||
+ * @param {function(Error)} callback Callback (optional).
|
|
||||||
+ * @param {object} ctx Context object (optional), only for nodejs v10+.
|
|
||||||
+ * @return {*} The return if no callback is provided.
|
|
||||||
+ */
|
|
||||||
+Binding.prototype.exists = function (filepath, callback, ctx) {
|
|
||||||
+ markSyscall(ctx, 'exists');
|
|
||||||
+
|
|
||||||
+ return maybeCallback(normalizeCallback(callback), ctx, this, function () {
|
|
||||||
+ filepath = deBuffer(filepath);
|
|
||||||
+ const item = this._system.getItem(filepath);
|
|
||||||
+
|
|
||||||
+ if (item) {
|
|
||||||
+ if (item instanceof SymbolicLink) {
|
|
||||||
+ return this.exists(item.getPath(), callback, ctx);
|
|
||||||
+ }
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+ return false;
|
|
||||||
+ });
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * Tests whether or not the given path exists.
|
|
||||||
+ * @param {string} filepath Path.
|
|
||||||
+ * @param {object} ctx Context object (optional), only for nodejs v10+.
|
|
||||||
+ * @return {*} The return if no callback is provided.
|
|
||||||
+ */
|
|
||||||
+Binding.prototype.existsSync = function (filepath, ctx) {
|
|
||||||
+ return this.exists(filepath, undefined, ctx);
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Not yet implemented.
|
|
||||||
* @type {function()}
|
|
||||||
diff --git a/test/lib/bypass.spec.js b/test/lib/bypass.spec.js
|
|
||||||
index 23bbc49..078cf81 100644
|
|
||||||
--- a/test/lib/bypass.spec.js
|
|
||||||
+++ b/test/lib/bypass.spec.js
|
|
||||||
@@ -13,7 +13,7 @@ describe('mock.bypass()', () => {
|
|
||||||
it('runs a synchronous function using the real filesystem', () => {
|
|
||||||
mock({'/path/to/file': 'content'});
|
|
||||||
|
|
||||||
- assert.equal(fs.readFileSync('/path/to/file', 'utf8'), 'content');
|
|
||||||
+ assert.equal(fs.readFileSync('/path/to/file', 'utf-8'), 'content');
|
|
||||||
assert.isNotOk(fs.existsSync(__filename));
|
|
||||||
assert.isOk(mock.bypass(() => fs.existsSync(__filename)));
|
|
||||||
|
|
||||||
Binary file not shown.
BIN
nodejs-mock-fs-5.4.1.tar.gz
Normal file
BIN
nodejs-mock-fs-5.4.1.tar.gz
Normal file
Binary file not shown.
@ -1,15 +1,13 @@
|
|||||||
%{?nodejs_find_provides_and_requires}
|
%{?nodejs_find_provides_and_requires}
|
||||||
|
|
||||||
Name: nodejs-mock-fs
|
Name: nodejs-mock-fs
|
||||||
Version: 5.2.0
|
Version: 5.4.1
|
||||||
Release: 2
|
Release: 1
|
||||||
Summary: A configurable mock file system
|
Summary: A configurable mock file system
|
||||||
|
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: https://www.npmjs.com/package/mock-fs
|
URL: https://www.npmjs.com/package/mock-fs
|
||||||
Source0: https://github.com/tschaub/mock-fs/archive/v%{version}/%{name}-%{version}.tar.gz
|
Source0: https://github.com/tschaub/mock-fs/archive/v%{version}/%{name}-%{version}.tar.gz
|
||||||
Patch1: Mock-sync-methods-to-support-v20.8.patch
|
|
||||||
Patch2: Create-mock-file-before-read.patch
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
ExclusiveArch: %{nodejs_arches} noarch
|
ExclusiveArch: %{nodejs_arches} noarch
|
||||||
|
|
||||||
@ -52,6 +50,9 @@ cp -pr package.json lib %{buildroot}%{nodejs_sitelib}/mock-fs
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Jan 24 2025 wangkai <13474090681@163.com> - 5.4.1-1
|
||||||
|
- Update to 5.4.1 for fix nodejs upgrade
|
||||||
|
|
||||||
* Thu Apr 25 2024 Ge Wang <wang__ge@126.com> - 5.2.0-2
|
* Thu Apr 25 2024 Ge Wang <wang__ge@126.com> - 5.2.0-2
|
||||||
- Fix check failure for nodejs20
|
- Fix check failure for nodejs20
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user