memfs 3.4.6 → 3.4.8
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 +11 -8
- package/lib/process.d.ts +2 -2
- package/lib/process.js +0 -4
- package/lib/volume.js +4 -4
- package/package.json +3 -2
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();
|
|
@@ -136,9 +138,10 @@ var Node = /** @class */ (function (_super) {
|
|
|
136
138
|
this.buf = this.buf.slice(0, len);
|
|
137
139
|
}
|
|
138
140
|
else {
|
|
139
|
-
var buf = (0, buffer_1.bufferAllocUnsafe)(
|
|
141
|
+
var buf = (0, buffer_1.bufferAllocUnsafe)(len);
|
|
140
142
|
this.buf.copy(buf);
|
|
141
|
-
buf.fill(0,
|
|
143
|
+
buf.fill(0, this.buf.length);
|
|
144
|
+
this.buf = buf;
|
|
142
145
|
}
|
|
143
146
|
}
|
|
144
147
|
this.touch();
|
|
@@ -158,8 +161,8 @@ var Node = /** @class */ (function (_super) {
|
|
|
158
161
|
this.emit('change', this);
|
|
159
162
|
};
|
|
160
163
|
Node.prototype.canRead = function (uid, gid) {
|
|
161
|
-
if (uid === void 0) { uid =
|
|
162
|
-
if (gid === void 0) { gid =
|
|
164
|
+
if (uid === void 0) { uid = getuid(); }
|
|
165
|
+
if (gid === void 0) { gid = getgid(); }
|
|
163
166
|
if (this.perm & 4 /* S.IROTH */) {
|
|
164
167
|
return true;
|
|
165
168
|
}
|
|
@@ -176,8 +179,8 @@ var Node = /** @class */ (function (_super) {
|
|
|
176
179
|
return false;
|
|
177
180
|
};
|
|
178
181
|
Node.prototype.canWrite = function (uid, gid) {
|
|
179
|
-
if (uid === void 0) { uid =
|
|
180
|
-
if (gid === void 0) { gid =
|
|
182
|
+
if (uid === void 0) { uid = getuid(); }
|
|
183
|
+
if (gid === void 0) { gid = getgid(); }
|
|
181
184
|
if (this.perm & 2 /* S.IWOTH */) {
|
|
182
185
|
return true;
|
|
183
186
|
}
|
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();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memfs",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.8",
|
|
4
4
|
"description": "In-memory file-system with Node's fs API.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"watch": "watch \"npm run build\" ./src",
|
|
17
17
|
"prettier": "prettier --ignore-path .gitignore --write \"src/**/*.{ts,js}\"",
|
|
18
18
|
"prettier:diff": "prettier -l \"src/**/*.{ts,js}\"",
|
|
19
|
-
"tslint": "tslint \"src/**/*.ts\" -t verbose"
|
|
19
|
+
"tslint": "tslint \"src/**/*.ts\" -t verbose",
|
|
20
|
+
"typecheck": "tsc -p ."
|
|
20
21
|
},
|
|
21
22
|
"repository": {
|
|
22
23
|
"type": "git",
|