memfs 3.4.6 → 3.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/node.js +8 -6
- package/lib/process.d.ts +2 -2
- package/lib/process.js +0 -4
- package/lib/volume.js +4 -4
- package/package.json +1 -1
package/lib/node.js
CHANGED
|
@@ -22,6 +22,8 @@ var constants_1 = require("./constants");
|
|
|
22
22
|
var events_1 = require("events");
|
|
23
23
|
var Stats_1 = require("./Stats");
|
|
24
24
|
var S_IFMT = constants_1.constants.S_IFMT, S_IFDIR = constants_1.constants.S_IFDIR, S_IFREG = constants_1.constants.S_IFREG, S_IFLNK = constants_1.constants.S_IFLNK, O_APPEND = constants_1.constants.O_APPEND;
|
|
25
|
+
var getuid = function () { var _a, _b; return (_b = (_a = process_1.default.getuid) === null || _a === void 0 ? void 0 : _a.call(process_1.default)) !== null && _b !== void 0 ? _b : 0; };
|
|
26
|
+
var getgid = function () { var _a, _b; return (_b = (_a = process_1.default.getgid) === null || _a === void 0 ? void 0 : _a.call(process_1.default)) !== null && _b !== void 0 ? _b : 0; };
|
|
25
27
|
exports.SEP = '/';
|
|
26
28
|
/**
|
|
27
29
|
* Node in a file system (like i-node, v-node).
|
|
@@ -32,8 +34,8 @@ var Node = /** @class */ (function (_super) {
|
|
|
32
34
|
if (perm === void 0) { perm = 438; }
|
|
33
35
|
var _this = _super.call(this) || this;
|
|
34
36
|
// User ID and group ID.
|
|
35
|
-
_this.uid =
|
|
36
|
-
_this.gid =
|
|
37
|
+
_this.uid = getuid();
|
|
38
|
+
_this.gid = getgid();
|
|
37
39
|
_this.atime = new Date();
|
|
38
40
|
_this.mtime = new Date();
|
|
39
41
|
_this.ctime = new Date();
|
|
@@ -158,8 +160,8 @@ var Node = /** @class */ (function (_super) {
|
|
|
158
160
|
this.emit('change', this);
|
|
159
161
|
};
|
|
160
162
|
Node.prototype.canRead = function (uid, gid) {
|
|
161
|
-
if (uid === void 0) { uid =
|
|
162
|
-
if (gid === void 0) { gid =
|
|
163
|
+
if (uid === void 0) { uid = getuid(); }
|
|
164
|
+
if (gid === void 0) { gid = getgid(); }
|
|
163
165
|
if (this.perm & 4 /* S.IROTH */) {
|
|
164
166
|
return true;
|
|
165
167
|
}
|
|
@@ -176,8 +178,8 @@ var Node = /** @class */ (function (_super) {
|
|
|
176
178
|
return false;
|
|
177
179
|
};
|
|
178
180
|
Node.prototype.canWrite = function (uid, gid) {
|
|
179
|
-
if (uid === void 0) { uid =
|
|
180
|
-
if (gid === void 0) { gid =
|
|
181
|
+
if (uid === void 0) { uid = getuid(); }
|
|
182
|
+
if (gid === void 0) { gid = getgid(); }
|
|
181
183
|
if (this.perm & 2 /* S.IWOTH */) {
|
|
182
184
|
return true;
|
|
183
185
|
}
|
package/lib/process.d.ts
CHANGED
package/lib/process.js
CHANGED
|
@@ -25,10 +25,6 @@ var maybeReturnProcess = function () {
|
|
|
25
25
|
};
|
|
26
26
|
function createProcess() {
|
|
27
27
|
var p = maybeReturnProcess() || {};
|
|
28
|
-
if (!p.getuid)
|
|
29
|
-
p.getuid = function () { return 0; };
|
|
30
|
-
if (!p.getgid)
|
|
31
|
-
p.getgid = function () { return 0; };
|
|
32
28
|
if (!p.cwd)
|
|
33
29
|
p.cwd = function () { return '/'; };
|
|
34
30
|
if (!p.nextTick)
|
package/lib/volume.js
CHANGED
|
@@ -1770,9 +1770,7 @@ var Volume = /** @class */ (function () {
|
|
|
1770
1770
|
this.wrapAsync(this.chownBase, [pathToFilename(path), uid, gid], callback);
|
|
1771
1771
|
};
|
|
1772
1772
|
Volume.prototype.lchownBase = function (filename, uid, gid) {
|
|
1773
|
-
this.getLinkOrThrow(filename, 'lchown')
|
|
1774
|
-
.getNode()
|
|
1775
|
-
.chown(uid, gid);
|
|
1773
|
+
this.getLinkOrThrow(filename, 'lchown').getNode().chown(uid, gid);
|
|
1776
1774
|
};
|
|
1777
1775
|
Volume.prototype.lchownSync = function (path, uid, gid) {
|
|
1778
1776
|
validateUid(uid);
|
|
@@ -1904,7 +1902,9 @@ var StatWatcher = /** @class */ (function (_super) {
|
|
|
1904
1902
|
if (persistent === void 0) { persistent = true; }
|
|
1905
1903
|
if (interval === void 0) { interval = 5007; }
|
|
1906
1904
|
this.filename = pathToFilename(path);
|
|
1907
|
-
this.setTimeout = persistent
|
|
1905
|
+
this.setTimeout = persistent
|
|
1906
|
+
? setTimeout.bind(typeof globalThis !== 'undefined' ? globalThis : global)
|
|
1907
|
+
: setTimeoutUnref_1.default;
|
|
1908
1908
|
this.interval = interval;
|
|
1909
1909
|
this.prev = this.vol.statSync(this.filename);
|
|
1910
1910
|
this.loop();
|