@andersbakken/fisk 3.6.0 → 3.6.2
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/dist/VM_runtime.js +422 -548
- package/dist/VM_runtime.js.map +1 -1
- package/dist/fisk-scheduler.js +268 -106
- package/dist/fisk-scheduler.js.map +1 -1
- package/package.json +6 -3
package/dist/VM_runtime.js
CHANGED
|
@@ -7,7 +7,7 @@ var require$$1 = require('fs');
|
|
|
7
7
|
var require$$0 = require('constants');
|
|
8
8
|
var require$$0$1 = require('stream');
|
|
9
9
|
var require$$4 = require('util');
|
|
10
|
-
var path$
|
|
10
|
+
var path$i = require('path');
|
|
11
11
|
var require$$1$1 = require('os');
|
|
12
12
|
|
|
13
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -19,7 +19,7 @@ var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
|
19
19
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
20
20
|
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
21
21
|
var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
|
|
22
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path$
|
|
22
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path$i);
|
|
23
23
|
var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
|
|
24
24
|
|
|
25
25
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
@@ -30,7 +30,7 @@ var lib = {
|
|
|
30
30
|
set exports(v){ libExports = v; },
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
var fs$
|
|
33
|
+
var fs$j = {};
|
|
34
34
|
|
|
35
35
|
var universalify = {};
|
|
36
36
|
|
|
@@ -555,7 +555,7 @@ function clone$1 (obj) {
|
|
|
555
555
|
return copy
|
|
556
556
|
}
|
|
557
557
|
|
|
558
|
-
var fs$
|
|
558
|
+
var fs$i = require$$1__default["default"];
|
|
559
559
|
var polyfills = polyfills$1;
|
|
560
560
|
var legacy = legacyStreams;
|
|
561
561
|
var clone = clone_1;
|
|
@@ -597,18 +597,18 @@ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ''))
|
|
|
597
597
|
};
|
|
598
598
|
|
|
599
599
|
// Once time initialization
|
|
600
|
-
if (!fs$
|
|
600
|
+
if (!fs$i[gracefulQueue]) {
|
|
601
601
|
// This queue can be shared by multiple loaded instances
|
|
602
602
|
var queue = commonjsGlobal[gracefulQueue] || [];
|
|
603
|
-
publishQueue(fs$
|
|
603
|
+
publishQueue(fs$i, queue);
|
|
604
604
|
|
|
605
605
|
// Patch fs.close/closeSync to shared queue version, because we need
|
|
606
606
|
// to retry() whenever a close happens *anywhere* in the program.
|
|
607
607
|
// This is essential when multiple graceful-fs instances are
|
|
608
608
|
// in play at the same time.
|
|
609
|
-
fs$
|
|
609
|
+
fs$i.close = (function (fs$close) {
|
|
610
610
|
function close (fd, cb) {
|
|
611
|
-
return fs$close.call(fs$
|
|
611
|
+
return fs$close.call(fs$i, fd, function (err) {
|
|
612
612
|
// This function uses the graceful-fs shared queue
|
|
613
613
|
if (!err) {
|
|
614
614
|
resetQueue();
|
|
@@ -623,12 +623,12 @@ if (!fs$j[gracefulQueue]) {
|
|
|
623
623
|
value: fs$close
|
|
624
624
|
});
|
|
625
625
|
return close
|
|
626
|
-
})(fs$
|
|
626
|
+
})(fs$i.close);
|
|
627
627
|
|
|
628
|
-
fs$
|
|
628
|
+
fs$i.closeSync = (function (fs$closeSync) {
|
|
629
629
|
function closeSync (fd) {
|
|
630
630
|
// This function uses the graceful-fs shared queue
|
|
631
|
-
fs$closeSync.apply(fs$
|
|
631
|
+
fs$closeSync.apply(fs$i, arguments);
|
|
632
632
|
resetQueue();
|
|
633
633
|
}
|
|
634
634
|
|
|
@@ -636,24 +636,24 @@ if (!fs$j[gracefulQueue]) {
|
|
|
636
636
|
value: fs$closeSync
|
|
637
637
|
});
|
|
638
638
|
return closeSync
|
|
639
|
-
})(fs$
|
|
639
|
+
})(fs$i.closeSync);
|
|
640
640
|
|
|
641
641
|
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
|
|
642
642
|
process.on('exit', function() {
|
|
643
|
-
debug(fs$
|
|
644
|
-
assert__default["default"].equal(fs$
|
|
643
|
+
debug(fs$i[gracefulQueue]);
|
|
644
|
+
assert__default["default"].equal(fs$i[gracefulQueue].length, 0);
|
|
645
645
|
});
|
|
646
646
|
}
|
|
647
647
|
}
|
|
648
648
|
|
|
649
649
|
if (!commonjsGlobal[gracefulQueue]) {
|
|
650
|
-
publishQueue(commonjsGlobal, fs$
|
|
650
|
+
publishQueue(commonjsGlobal, fs$i[gracefulQueue]);
|
|
651
651
|
}
|
|
652
652
|
|
|
653
|
-
var gracefulFs = patch(clone(fs$
|
|
654
|
-
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$
|
|
655
|
-
gracefulFs = patch(fs$
|
|
656
|
-
fs$
|
|
653
|
+
var gracefulFs = patch(clone(fs$i));
|
|
654
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$i.__patched) {
|
|
655
|
+
gracefulFs = patch(fs$i);
|
|
656
|
+
fs$i.__patched = true;
|
|
657
657
|
}
|
|
658
658
|
|
|
659
659
|
function patch (fs) {
|
|
@@ -927,7 +927,7 @@ function patch (fs) {
|
|
|
927
927
|
|
|
928
928
|
function enqueue (elem) {
|
|
929
929
|
debug('ENQUEUE', elem[0].name, elem[1]);
|
|
930
|
-
fs$
|
|
930
|
+
fs$i[gracefulQueue].push(elem);
|
|
931
931
|
retry();
|
|
932
932
|
}
|
|
933
933
|
|
|
@@ -939,12 +939,12 @@ var retryTimer;
|
|
|
939
939
|
// delay between attempts so that we'll retry these jobs sooner
|
|
940
940
|
function resetQueue () {
|
|
941
941
|
var now = Date.now();
|
|
942
|
-
for (var i = 0; i < fs$
|
|
942
|
+
for (var i = 0; i < fs$i[gracefulQueue].length; ++i) {
|
|
943
943
|
// entries that are only a length of 2 are from an older version, don't
|
|
944
944
|
// bother modifying those since they'll be retried anyway.
|
|
945
|
-
if (fs$
|
|
946
|
-
fs$
|
|
947
|
-
fs$
|
|
945
|
+
if (fs$i[gracefulQueue][i].length > 2) {
|
|
946
|
+
fs$i[gracefulQueue][i][3] = now; // startTime
|
|
947
|
+
fs$i[gracefulQueue][i][4] = now; // lastTime
|
|
948
948
|
}
|
|
949
949
|
}
|
|
950
950
|
// call retry to make sure we're actively processing the queue
|
|
@@ -956,10 +956,10 @@ function retry () {
|
|
|
956
956
|
clearTimeout(retryTimer);
|
|
957
957
|
retryTimer = undefined;
|
|
958
958
|
|
|
959
|
-
if (fs$
|
|
959
|
+
if (fs$i[gracefulQueue].length === 0)
|
|
960
960
|
return
|
|
961
961
|
|
|
962
|
-
var elem = fs$
|
|
962
|
+
var elem = fs$i[gracefulQueue].shift();
|
|
963
963
|
var fn = elem[0];
|
|
964
964
|
var args = elem[1];
|
|
965
965
|
// these items may be unset if they were added by an older graceful-fs
|
|
@@ -994,7 +994,7 @@ function retry () {
|
|
|
994
994
|
} else {
|
|
995
995
|
// if we can't do this job yet, push it to the end of the queue
|
|
996
996
|
// and let the next iteration check again
|
|
997
|
-
fs$
|
|
997
|
+
fs$i[gracefulQueue].push(elem);
|
|
998
998
|
}
|
|
999
999
|
}
|
|
1000
1000
|
|
|
@@ -1107,13 +1107,13 @@ function retry () {
|
|
|
1107
1107
|
});
|
|
1108
1108
|
})
|
|
1109
1109
|
};
|
|
1110
|
-
} (fs$
|
|
1110
|
+
} (fs$j));
|
|
1111
1111
|
|
|
1112
|
-
const path$
|
|
1112
|
+
const path$h = path__default["default"];
|
|
1113
1113
|
|
|
1114
1114
|
// get drive on windows
|
|
1115
1115
|
function getRootPath (p) {
|
|
1116
|
-
p = path$
|
|
1116
|
+
p = path$h.normalize(path$h.resolve(p)).split(path$h.sep);
|
|
1117
1117
|
if (p.length > 0) return p[0]
|
|
1118
1118
|
return null
|
|
1119
1119
|
}
|
|
@@ -1133,8 +1133,8 @@ var win32 = {
|
|
|
1133
1133
|
invalidWin32Path: invalidWin32Path$2
|
|
1134
1134
|
};
|
|
1135
1135
|
|
|
1136
|
-
const fs$
|
|
1137
|
-
const path$
|
|
1136
|
+
const fs$h = gracefulFs;
|
|
1137
|
+
const path$g = path__default["default"];
|
|
1138
1138
|
const invalidWin32Path$1 = win32.invalidWin32Path;
|
|
1139
1139
|
|
|
1140
1140
|
const o777$1 = parseInt('0777', 8);
|
|
@@ -1154,7 +1154,7 @@ function mkdirs$2 (p, opts, callback, made) {
|
|
|
1154
1154
|
}
|
|
1155
1155
|
|
|
1156
1156
|
let mode = opts.mode;
|
|
1157
|
-
const xfs = opts.fs || fs$
|
|
1157
|
+
const xfs = opts.fs || fs$h;
|
|
1158
1158
|
|
|
1159
1159
|
if (mode === undefined) {
|
|
1160
1160
|
mode = o777$1 & (~process.umask());
|
|
@@ -1162,7 +1162,7 @@ function mkdirs$2 (p, opts, callback, made) {
|
|
|
1162
1162
|
if (!made) made = null;
|
|
1163
1163
|
|
|
1164
1164
|
callback = callback || function () {};
|
|
1165
|
-
p = path$
|
|
1165
|
+
p = path$g.resolve(p);
|
|
1166
1166
|
|
|
1167
1167
|
xfs.mkdir(p, mode, er => {
|
|
1168
1168
|
if (!er) {
|
|
@@ -1171,8 +1171,8 @@ function mkdirs$2 (p, opts, callback, made) {
|
|
|
1171
1171
|
}
|
|
1172
1172
|
switch (er.code) {
|
|
1173
1173
|
case 'ENOENT':
|
|
1174
|
-
if (path$
|
|
1175
|
-
mkdirs$2(path$
|
|
1174
|
+
if (path$g.dirname(p) === p) return callback(er)
|
|
1175
|
+
mkdirs$2(path$g.dirname(p), opts, (er, made) => {
|
|
1176
1176
|
if (er) callback(er, made);
|
|
1177
1177
|
else mkdirs$2(p, opts, callback, made);
|
|
1178
1178
|
});
|
|
@@ -1195,8 +1195,8 @@ function mkdirs$2 (p, opts, callback, made) {
|
|
|
1195
1195
|
|
|
1196
1196
|
var mkdirs_1$1 = mkdirs$2;
|
|
1197
1197
|
|
|
1198
|
-
const fs$
|
|
1199
|
-
const path$
|
|
1198
|
+
const fs$g = gracefulFs;
|
|
1199
|
+
const path$f = path__default["default"];
|
|
1200
1200
|
const invalidWin32Path = win32.invalidWin32Path;
|
|
1201
1201
|
|
|
1202
1202
|
const o777 = parseInt('0777', 8);
|
|
@@ -1207,7 +1207,7 @@ function mkdirsSync$2 (p, opts, made) {
|
|
|
1207
1207
|
}
|
|
1208
1208
|
|
|
1209
1209
|
let mode = opts.mode;
|
|
1210
|
-
const xfs = opts.fs || fs$
|
|
1210
|
+
const xfs = opts.fs || fs$g;
|
|
1211
1211
|
|
|
1212
1212
|
if (process.platform === 'win32' && invalidWin32Path(p)) {
|
|
1213
1213
|
const errInval = new Error(p + ' contains invalid WIN32 path characters.');
|
|
@@ -1220,15 +1220,15 @@ function mkdirsSync$2 (p, opts, made) {
|
|
|
1220
1220
|
}
|
|
1221
1221
|
if (!made) made = null;
|
|
1222
1222
|
|
|
1223
|
-
p = path$
|
|
1223
|
+
p = path$f.resolve(p);
|
|
1224
1224
|
|
|
1225
1225
|
try {
|
|
1226
1226
|
xfs.mkdirSync(p, mode);
|
|
1227
1227
|
made = made || p;
|
|
1228
1228
|
} catch (err0) {
|
|
1229
1229
|
if (err0.code === 'ENOENT') {
|
|
1230
|
-
if (path$
|
|
1231
|
-
made = mkdirsSync$2(path$
|
|
1230
|
+
if (path$f.dirname(p) === p) throw err0
|
|
1231
|
+
made = mkdirsSync$2(path$f.dirname(p), opts, made);
|
|
1232
1232
|
mkdirsSync$2(p, opts, made);
|
|
1233
1233
|
} else {
|
|
1234
1234
|
// In the case of any other error, just see if there's a dir there
|
|
@@ -1262,39 +1262,39 @@ var mkdirs_1 = {
|
|
|
1262
1262
|
ensureDirSync: mkdirsSync$1
|
|
1263
1263
|
};
|
|
1264
1264
|
|
|
1265
|
-
const fs$
|
|
1265
|
+
const fs$f = gracefulFs;
|
|
1266
1266
|
const os = require$$1__default$1["default"];
|
|
1267
|
-
const path$
|
|
1267
|
+
const path$e = path__default["default"];
|
|
1268
1268
|
|
|
1269
1269
|
// HFS, ext{2,3}, FAT do not, Node.js v0.10 does not
|
|
1270
1270
|
function hasMillisResSync () {
|
|
1271
|
-
let tmpfile = path$
|
|
1272
|
-
tmpfile = path$
|
|
1271
|
+
let tmpfile = path$e.join('millis-test-sync' + Date.now().toString() + Math.random().toString().slice(2));
|
|
1272
|
+
tmpfile = path$e.join(os.tmpdir(), tmpfile);
|
|
1273
1273
|
|
|
1274
1274
|
// 550 millis past UNIX epoch
|
|
1275
1275
|
const d = new Date(1435410243862);
|
|
1276
|
-
fs$
|
|
1277
|
-
const fd = fs$
|
|
1278
|
-
fs$
|
|
1279
|
-
fs$
|
|
1280
|
-
return fs$
|
|
1276
|
+
fs$f.writeFileSync(tmpfile, 'https://github.com/jprichardson/node-fs-extra/pull/141');
|
|
1277
|
+
const fd = fs$f.openSync(tmpfile, 'r+');
|
|
1278
|
+
fs$f.futimesSync(fd, d, d);
|
|
1279
|
+
fs$f.closeSync(fd);
|
|
1280
|
+
return fs$f.statSync(tmpfile).mtime > 1435410243000
|
|
1281
1281
|
}
|
|
1282
1282
|
|
|
1283
1283
|
function hasMillisRes (callback) {
|
|
1284
|
-
let tmpfile = path$
|
|
1285
|
-
tmpfile = path$
|
|
1284
|
+
let tmpfile = path$e.join('millis-test' + Date.now().toString() + Math.random().toString().slice(2));
|
|
1285
|
+
tmpfile = path$e.join(os.tmpdir(), tmpfile);
|
|
1286
1286
|
|
|
1287
1287
|
// 550 millis past UNIX epoch
|
|
1288
1288
|
const d = new Date(1435410243862);
|
|
1289
|
-
fs$
|
|
1289
|
+
fs$f.writeFile(tmpfile, 'https://github.com/jprichardson/node-fs-extra/pull/141', err => {
|
|
1290
1290
|
if (err) return callback(err)
|
|
1291
|
-
fs$
|
|
1291
|
+
fs$f.open(tmpfile, 'r+', (err, fd) => {
|
|
1292
1292
|
if (err) return callback(err)
|
|
1293
|
-
fs$
|
|
1293
|
+
fs$f.futimes(fd, d, d, err => {
|
|
1294
1294
|
if (err) return callback(err)
|
|
1295
|
-
fs$
|
|
1295
|
+
fs$f.close(fd, err => {
|
|
1296
1296
|
if (err) return callback(err)
|
|
1297
|
-
fs$
|
|
1297
|
+
fs$f.stat(tmpfile, (err, stats) => {
|
|
1298
1298
|
if (err) return callback(err)
|
|
1299
1299
|
callback(null, stats.mtime > 1435410243000);
|
|
1300
1300
|
});
|
|
@@ -1316,10 +1316,10 @@ function timeRemoveMillis (timestamp) {
|
|
|
1316
1316
|
|
|
1317
1317
|
function utimesMillis (path, atime, mtime, callback) {
|
|
1318
1318
|
// if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
|
|
1319
|
-
fs$
|
|
1319
|
+
fs$f.open(path, 'r+', (err, fd) => {
|
|
1320
1320
|
if (err) return callback(err)
|
|
1321
|
-
fs$
|
|
1322
|
-
fs$
|
|
1321
|
+
fs$f.futimes(fd, atime, mtime, futimesErr => {
|
|
1322
|
+
fs$f.close(fd, closeErr => {
|
|
1323
1323
|
if (callback) callback(futimesErr || closeErr);
|
|
1324
1324
|
});
|
|
1325
1325
|
});
|
|
@@ -1327,9 +1327,9 @@ function utimesMillis (path, atime, mtime, callback) {
|
|
|
1327
1327
|
}
|
|
1328
1328
|
|
|
1329
1329
|
function utimesMillisSync (path, atime, mtime) {
|
|
1330
|
-
const fd = fs$
|
|
1331
|
-
fs$
|
|
1332
|
-
return fs$
|
|
1330
|
+
const fd = fs$f.openSync(path, 'r+');
|
|
1331
|
+
fs$f.futimesSync(fd, atime, mtime);
|
|
1332
|
+
return fs$f.closeSync(fd)
|
|
1333
1333
|
}
|
|
1334
1334
|
|
|
1335
1335
|
var utimes$1 = {
|
|
@@ -1352,8 +1352,8 @@ var buffer$1 = function (size) {
|
|
|
1352
1352
|
return new Buffer(size)
|
|
1353
1353
|
};
|
|
1354
1354
|
|
|
1355
|
-
const fs$
|
|
1356
|
-
const path$
|
|
1355
|
+
const fs$e = gracefulFs;
|
|
1356
|
+
const path$d = path__default["default"];
|
|
1357
1357
|
const mkdirpSync$1 = mkdirs_1.mkdirsSync;
|
|
1358
1358
|
const utimesSync = utimes$1.utimesMillisSync;
|
|
1359
1359
|
|
|
@@ -1379,8 +1379,8 @@ function copySync$2 (src, dest, opts) {
|
|
|
1379
1379
|
|
|
1380
1380
|
if (opts.filter && !opts.filter(src, dest)) return
|
|
1381
1381
|
|
|
1382
|
-
const destParent = path$
|
|
1383
|
-
if (!fs$
|
|
1382
|
+
const destParent = path$d.dirname(dest);
|
|
1383
|
+
if (!fs$e.existsSync(destParent)) mkdirpSync$1(destParent);
|
|
1384
1384
|
return startCopy$1(resolvedDest, src, dest, opts)
|
|
1385
1385
|
}
|
|
1386
1386
|
|
|
@@ -1390,7 +1390,7 @@ function startCopy$1 (resolvedDest, src, dest, opts) {
|
|
|
1390
1390
|
}
|
|
1391
1391
|
|
|
1392
1392
|
function getStats$1 (resolvedDest, src, dest, opts) {
|
|
1393
|
-
const statSync = opts.dereference ? fs$
|
|
1393
|
+
const statSync = opts.dereference ? fs$e.statSync : fs$e.lstatSync;
|
|
1394
1394
|
const st = statSync(src);
|
|
1395
1395
|
|
|
1396
1396
|
if (st.isDirectory()) return onDir$1(st, resolvedDest, src, dest, opts)
|
|
@@ -1408,7 +1408,7 @@ function onFile$1 (srcStat, resolvedDest, src, dest, opts) {
|
|
|
1408
1408
|
|
|
1409
1409
|
function mayCopyFile$1 (srcStat, src, dest, opts) {
|
|
1410
1410
|
if (opts.overwrite) {
|
|
1411
|
-
fs$
|
|
1411
|
+
fs$e.unlinkSync(dest);
|
|
1412
1412
|
return copyFile$1(srcStat, src, dest, opts)
|
|
1413
1413
|
} else if (opts.errorOnExist) {
|
|
1414
1414
|
throw new Error(`'${dest}' already exists`)
|
|
@@ -1416,9 +1416,9 @@ function mayCopyFile$1 (srcStat, src, dest, opts) {
|
|
|
1416
1416
|
}
|
|
1417
1417
|
|
|
1418
1418
|
function copyFile$1 (srcStat, src, dest, opts) {
|
|
1419
|
-
if (typeof fs$
|
|
1420
|
-
fs$
|
|
1421
|
-
fs$
|
|
1419
|
+
if (typeof fs$e.copyFileSync === 'function') {
|
|
1420
|
+
fs$e.copyFileSync(src, dest);
|
|
1421
|
+
fs$e.chmodSync(dest, srcStat.mode);
|
|
1422
1422
|
if (opts.preserveTimestamps) {
|
|
1423
1423
|
return utimesSync(dest, srcStat.atime, srcStat.mtime)
|
|
1424
1424
|
}
|
|
@@ -1431,20 +1431,20 @@ function copyFileFallback$1 (srcStat, src, dest, opts) {
|
|
|
1431
1431
|
const BUF_LENGTH = 64 * 1024;
|
|
1432
1432
|
const _buff = buffer$1(BUF_LENGTH);
|
|
1433
1433
|
|
|
1434
|
-
const fdr = fs$
|
|
1435
|
-
const fdw = fs$
|
|
1434
|
+
const fdr = fs$e.openSync(src, 'r');
|
|
1435
|
+
const fdw = fs$e.openSync(dest, 'w', srcStat.mode);
|
|
1436
1436
|
let pos = 0;
|
|
1437
1437
|
|
|
1438
1438
|
while (pos < srcStat.size) {
|
|
1439
|
-
const bytesRead = fs$
|
|
1440
|
-
fs$
|
|
1439
|
+
const bytesRead = fs$e.readSync(fdr, _buff, 0, BUF_LENGTH, pos);
|
|
1440
|
+
fs$e.writeSync(fdw, _buff, 0, bytesRead);
|
|
1441
1441
|
pos += bytesRead;
|
|
1442
1442
|
}
|
|
1443
1443
|
|
|
1444
|
-
if (opts.preserveTimestamps) fs$
|
|
1444
|
+
if (opts.preserveTimestamps) fs$e.futimesSync(fdw, srcStat.atime, srcStat.mtime);
|
|
1445
1445
|
|
|
1446
|
-
fs$
|
|
1447
|
-
fs$
|
|
1446
|
+
fs$e.closeSync(fdr);
|
|
1447
|
+
fs$e.closeSync(fdw);
|
|
1448
1448
|
}
|
|
1449
1449
|
|
|
1450
1450
|
function onDir$1 (srcStat, resolvedDest, src, dest, opts) {
|
|
@@ -1463,50 +1463,50 @@ function onDir$1 (srcStat, resolvedDest, src, dest, opts) {
|
|
|
1463
1463
|
}
|
|
1464
1464
|
|
|
1465
1465
|
function mayCopyDir$1 (src, dest, opts) {
|
|
1466
|
-
if (!fs$
|
|
1466
|
+
if (!fs$e.statSync(dest).isDirectory()) {
|
|
1467
1467
|
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
|
|
1468
1468
|
}
|
|
1469
1469
|
return copyDir$1(src, dest, opts)
|
|
1470
1470
|
}
|
|
1471
1471
|
|
|
1472
1472
|
function mkDirAndCopy$1 (srcStat, src, dest, opts) {
|
|
1473
|
-
fs$
|
|
1474
|
-
fs$
|
|
1473
|
+
fs$e.mkdirSync(dest, srcStat.mode);
|
|
1474
|
+
fs$e.chmodSync(dest, srcStat.mode);
|
|
1475
1475
|
return copyDir$1(src, dest, opts)
|
|
1476
1476
|
}
|
|
1477
1477
|
|
|
1478
1478
|
function copyDir$1 (src, dest, opts) {
|
|
1479
|
-
fs$
|
|
1479
|
+
fs$e.readdirSync(src).forEach(item => copyDirItem$1(item, src, dest, opts));
|
|
1480
1480
|
}
|
|
1481
1481
|
|
|
1482
1482
|
function copyDirItem$1 (item, src, dest, opts) {
|
|
1483
|
-
const srcItem = path$
|
|
1484
|
-
const destItem = path$
|
|
1483
|
+
const srcItem = path$d.join(src, item);
|
|
1484
|
+
const destItem = path$d.join(dest, item);
|
|
1485
1485
|
const resolvedDest = checkPaths$1(srcItem, destItem);
|
|
1486
1486
|
return startCopy$1(resolvedDest, srcItem, destItem, opts)
|
|
1487
1487
|
}
|
|
1488
1488
|
|
|
1489
1489
|
function onLink$1 (resolvedDest, src, dest, opts) {
|
|
1490
|
-
let resolvedSrc = fs$
|
|
1490
|
+
let resolvedSrc = fs$e.readlinkSync(src);
|
|
1491
1491
|
|
|
1492
1492
|
if (opts.dereference) {
|
|
1493
|
-
resolvedSrc = path$
|
|
1493
|
+
resolvedSrc = path$d.resolve(process.cwd(), resolvedSrc);
|
|
1494
1494
|
}
|
|
1495
1495
|
|
|
1496
1496
|
if (resolvedDest === notExist$1 || resolvedDest === existsReg$1) {
|
|
1497
1497
|
// if dest already exists, fs throws error anyway,
|
|
1498
1498
|
// so no need to guard against it here.
|
|
1499
|
-
return fs$
|
|
1499
|
+
return fs$e.symlinkSync(resolvedSrc, dest)
|
|
1500
1500
|
} else {
|
|
1501
1501
|
if (opts.dereference) {
|
|
1502
|
-
resolvedDest = path$
|
|
1502
|
+
resolvedDest = path$d.resolve(process.cwd(), resolvedDest);
|
|
1503
1503
|
}
|
|
1504
1504
|
if (pathsAreIdentical$1(resolvedSrc, resolvedDest)) return
|
|
1505
1505
|
|
|
1506
1506
|
// prevent copy if src is a subdir of dest since unlinking
|
|
1507
1507
|
// dest in this case would result in removing src contents
|
|
1508
1508
|
// and therefore a broken symlink would be created.
|
|
1509
|
-
if (fs$
|
|
1509
|
+
if (fs$e.statSync(dest).isDirectory() && isSrcSubdir$3(resolvedDest, resolvedSrc)) {
|
|
1510
1510
|
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
|
|
1511
1511
|
}
|
|
1512
1512
|
return copyLink$1(resolvedSrc, dest)
|
|
@@ -1514,15 +1514,15 @@ function onLink$1 (resolvedDest, src, dest, opts) {
|
|
|
1514
1514
|
}
|
|
1515
1515
|
|
|
1516
1516
|
function copyLink$1 (resolvedSrc, dest) {
|
|
1517
|
-
fs$
|
|
1518
|
-
return fs$
|
|
1517
|
+
fs$e.unlinkSync(dest);
|
|
1518
|
+
return fs$e.symlinkSync(resolvedSrc, dest)
|
|
1519
1519
|
}
|
|
1520
1520
|
|
|
1521
1521
|
// return true if dest is a subdir of src, otherwise false.
|
|
1522
1522
|
// extract dest base dir and check if that is the same as src basename.
|
|
1523
1523
|
function isSrcSubdir$3 (src, dest) {
|
|
1524
|
-
const srcArray = path$
|
|
1525
|
-
const destArray = path$
|
|
1524
|
+
const srcArray = path$d.resolve(src).split(path$d.sep);
|
|
1525
|
+
const destArray = path$d.resolve(dest).split(path$d.sep);
|
|
1526
1526
|
|
|
1527
1527
|
return srcArray.reduce((acc, current, i) => {
|
|
1528
1528
|
return acc && destArray[i] === current
|
|
@@ -1533,7 +1533,7 @@ function isSrcSubdir$3 (src, dest) {
|
|
|
1533
1533
|
function checkDest$1 (dest) {
|
|
1534
1534
|
let resolvedPath;
|
|
1535
1535
|
try {
|
|
1536
|
-
resolvedPath = fs$
|
|
1536
|
+
resolvedPath = fs$e.readlinkSync(dest);
|
|
1537
1537
|
} catch (err) {
|
|
1538
1538
|
if (err.code === 'ENOENT') return notExist$1
|
|
1539
1539
|
|
|
@@ -1547,8 +1547,8 @@ function checkDest$1 (dest) {
|
|
|
1547
1547
|
|
|
1548
1548
|
function pathsAreIdentical$1 (src, dest) {
|
|
1549
1549
|
const os = process.platform;
|
|
1550
|
-
const resolvedSrc = path$
|
|
1551
|
-
const resolvedDest = path$
|
|
1550
|
+
const resolvedSrc = path$d.resolve(src);
|
|
1551
|
+
const resolvedDest = path$d.resolve(dest);
|
|
1552
1552
|
// case-insensitive paths
|
|
1553
1553
|
if (os === 'darwin' || os === 'win32') {
|
|
1554
1554
|
return resolvedSrc.toLowerCase() === resolvedDest.toLowerCase()
|
|
@@ -1575,19 +1575,19 @@ var copySync$1 = {
|
|
|
1575
1575
|
};
|
|
1576
1576
|
|
|
1577
1577
|
const u$a = universalify.fromPromise;
|
|
1578
|
-
const fs$
|
|
1578
|
+
const fs$d = fs$j;
|
|
1579
1579
|
|
|
1580
1580
|
function pathExists$8 (path) {
|
|
1581
|
-
return fs$
|
|
1581
|
+
return fs$d.access(path).then(() => true).catch(() => false)
|
|
1582
1582
|
}
|
|
1583
1583
|
|
|
1584
1584
|
var pathExists_1 = {
|
|
1585
1585
|
pathExists: u$a(pathExists$8),
|
|
1586
|
-
pathExistsSync: fs$
|
|
1586
|
+
pathExistsSync: fs$d.existsSync
|
|
1587
1587
|
};
|
|
1588
1588
|
|
|
1589
|
-
const fs$
|
|
1590
|
-
const path$
|
|
1589
|
+
const fs$c = gracefulFs;
|
|
1590
|
+
const path$c = path__default["default"];
|
|
1591
1591
|
const mkdirp$1 = mkdirs_1.mkdirs;
|
|
1592
1592
|
const pathExists$7 = pathExists_1.pathExists;
|
|
1593
1593
|
const utimes = utimes$1.utimesMillis;
|
|
@@ -1623,7 +1623,7 @@ function copy$2 (src, dest, opts, cb) {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
|
|
1625
1625
|
function checkParentDir (resolvedDest, src, dest, opts, cb) {
|
|
1626
|
-
const destParent = path$
|
|
1626
|
+
const destParent = path$c.dirname(dest);
|
|
1627
1627
|
pathExists$7(destParent, (err, dirExists) => {
|
|
1628
1628
|
if (err) return cb(err)
|
|
1629
1629
|
if (dirExists) return startCopy(resolvedDest, src, dest, opts, cb)
|
|
@@ -1650,7 +1650,7 @@ function handleFilter (onInclude, resolvedDest, src, dest, opts, cb) {
|
|
|
1650
1650
|
}
|
|
1651
1651
|
|
|
1652
1652
|
function getStats (resolvedDest, src, dest, opts, cb) {
|
|
1653
|
-
const stat = opts.dereference ? fs$
|
|
1653
|
+
const stat = opts.dereference ? fs$c.stat : fs$c.lstat;
|
|
1654
1654
|
stat(src, (err, st) => {
|
|
1655
1655
|
if (err) return cb(err)
|
|
1656
1656
|
|
|
@@ -1670,7 +1670,7 @@ function onFile (srcStat, resolvedDest, src, dest, opts, cb) {
|
|
|
1670
1670
|
|
|
1671
1671
|
function mayCopyFile (srcStat, src, dest, opts, cb) {
|
|
1672
1672
|
if (opts.overwrite) {
|
|
1673
|
-
fs$
|
|
1673
|
+
fs$c.unlink(dest, err => {
|
|
1674
1674
|
if (err) return cb(err)
|
|
1675
1675
|
return copyFile(srcStat, src, dest, opts, cb)
|
|
1676
1676
|
});
|
|
@@ -1680,8 +1680,8 @@ function mayCopyFile (srcStat, src, dest, opts, cb) {
|
|
|
1680
1680
|
}
|
|
1681
1681
|
|
|
1682
1682
|
function copyFile (srcStat, src, dest, opts, cb) {
|
|
1683
|
-
if (typeof fs$
|
|
1684
|
-
return fs$
|
|
1683
|
+
if (typeof fs$c.copyFile === 'function') {
|
|
1684
|
+
return fs$c.copyFile(src, dest, err => {
|
|
1685
1685
|
if (err) return cb(err)
|
|
1686
1686
|
return setDestModeAndTimestamps(srcStat, dest, opts, cb)
|
|
1687
1687
|
})
|
|
@@ -1690,9 +1690,9 @@ function copyFile (srcStat, src, dest, opts, cb) {
|
|
|
1690
1690
|
}
|
|
1691
1691
|
|
|
1692
1692
|
function copyFileFallback (srcStat, src, dest, opts, cb) {
|
|
1693
|
-
const rs = fs$
|
|
1693
|
+
const rs = fs$c.createReadStream(src);
|
|
1694
1694
|
rs.on('error', err => cb(err)).once('open', () => {
|
|
1695
|
-
const ws = fs$
|
|
1695
|
+
const ws = fs$c.createWriteStream(dest, { mode: srcStat.mode });
|
|
1696
1696
|
ws.on('error', err => cb(err))
|
|
1697
1697
|
.on('open', () => rs.pipe(ws))
|
|
1698
1698
|
.once('close', () => setDestModeAndTimestamps(srcStat, dest, opts, cb));
|
|
@@ -1700,7 +1700,7 @@ function copyFileFallback (srcStat, src, dest, opts, cb) {
|
|
|
1700
1700
|
}
|
|
1701
1701
|
|
|
1702
1702
|
function setDestModeAndTimestamps (srcStat, dest, opts, cb) {
|
|
1703
|
-
fs$
|
|
1703
|
+
fs$c.chmod(dest, srcStat.mode, err => {
|
|
1704
1704
|
if (err) return cb(err)
|
|
1705
1705
|
if (opts.preserveTimestamps) {
|
|
1706
1706
|
return utimes(dest, srcStat.atime, srcStat.mtime, cb)
|
|
@@ -1725,7 +1725,7 @@ function onDir (srcStat, resolvedDest, src, dest, opts, cb) {
|
|
|
1725
1725
|
}
|
|
1726
1726
|
|
|
1727
1727
|
function mayCopyDir (src, dest, opts, cb) {
|
|
1728
|
-
fs$
|
|
1728
|
+
fs$c.stat(dest, (err, st) => {
|
|
1729
1729
|
if (err) return cb(err)
|
|
1730
1730
|
if (!st.isDirectory()) {
|
|
1731
1731
|
return cb(new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`))
|
|
@@ -1735,9 +1735,9 @@ function mayCopyDir (src, dest, opts, cb) {
|
|
|
1735
1735
|
}
|
|
1736
1736
|
|
|
1737
1737
|
function mkDirAndCopy (srcStat, src, dest, opts, cb) {
|
|
1738
|
-
fs$
|
|
1738
|
+
fs$c.mkdir(dest, srcStat.mode, err => {
|
|
1739
1739
|
if (err) return cb(err)
|
|
1740
|
-
fs$
|
|
1740
|
+
fs$c.chmod(dest, srcStat.mode, err => {
|
|
1741
1741
|
if (err) return cb(err)
|
|
1742
1742
|
return copyDir(src, dest, opts, cb)
|
|
1743
1743
|
});
|
|
@@ -1745,7 +1745,7 @@ function mkDirAndCopy (srcStat, src, dest, opts, cb) {
|
|
|
1745
1745
|
}
|
|
1746
1746
|
|
|
1747
1747
|
function copyDir (src, dest, opts, cb) {
|
|
1748
|
-
fs$
|
|
1748
|
+
fs$c.readdir(src, (err, items) => {
|
|
1749
1749
|
if (err) return cb(err)
|
|
1750
1750
|
return copyDirItems(items, src, dest, opts, cb)
|
|
1751
1751
|
});
|
|
@@ -1758,8 +1758,8 @@ function copyDirItems (items, src, dest, opts, cb) {
|
|
|
1758
1758
|
}
|
|
1759
1759
|
|
|
1760
1760
|
function copyDirItem (items, item, src, dest, opts, cb) {
|
|
1761
|
-
const srcItem = path$
|
|
1762
|
-
const destItem = path$
|
|
1761
|
+
const srcItem = path$c.join(src, item);
|
|
1762
|
+
const destItem = path$c.join(dest, item);
|
|
1763
1763
|
checkPaths(srcItem, destItem, (err, resolvedDest) => {
|
|
1764
1764
|
if (err) return cb(err)
|
|
1765
1765
|
startCopy(resolvedDest, srcItem, destItem, opts, err => {
|
|
@@ -1770,27 +1770,27 @@ function copyDirItem (items, item, src, dest, opts, cb) {
|
|
|
1770
1770
|
}
|
|
1771
1771
|
|
|
1772
1772
|
function onLink (resolvedDest, src, dest, opts, cb) {
|
|
1773
|
-
fs$
|
|
1773
|
+
fs$c.readlink(src, (err, resolvedSrc) => {
|
|
1774
1774
|
if (err) return cb(err)
|
|
1775
1775
|
|
|
1776
1776
|
if (opts.dereference) {
|
|
1777
|
-
resolvedSrc = path$
|
|
1777
|
+
resolvedSrc = path$c.resolve(process.cwd(), resolvedSrc);
|
|
1778
1778
|
}
|
|
1779
1779
|
|
|
1780
1780
|
if (resolvedDest === notExist || resolvedDest === existsReg) {
|
|
1781
1781
|
// if dest already exists, fs throws error anyway,
|
|
1782
1782
|
// so no need to guard against it here.
|
|
1783
|
-
return fs$
|
|
1783
|
+
return fs$c.symlink(resolvedSrc, dest, cb)
|
|
1784
1784
|
} else {
|
|
1785
1785
|
if (opts.dereference) {
|
|
1786
|
-
resolvedDest = path$
|
|
1786
|
+
resolvedDest = path$c.resolve(process.cwd(), resolvedDest);
|
|
1787
1787
|
}
|
|
1788
1788
|
if (pathsAreIdentical(resolvedSrc, resolvedDest)) return cb()
|
|
1789
1789
|
|
|
1790
1790
|
// prevent copy if src is a subdir of dest since unlinking
|
|
1791
1791
|
// dest in this case would result in removing src contents
|
|
1792
1792
|
// and therefore a broken symlink would be created.
|
|
1793
|
-
fs$
|
|
1793
|
+
fs$c.stat(dest, (err, st) => {
|
|
1794
1794
|
if (err) return cb(err)
|
|
1795
1795
|
if (st.isDirectory() && isSrcSubdir$2(resolvedDest, resolvedSrc)) {
|
|
1796
1796
|
return cb(new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`))
|
|
@@ -1802,17 +1802,17 @@ function onLink (resolvedDest, src, dest, opts, cb) {
|
|
|
1802
1802
|
}
|
|
1803
1803
|
|
|
1804
1804
|
function copyLink (resolvedSrc, dest, cb) {
|
|
1805
|
-
fs$
|
|
1805
|
+
fs$c.unlink(dest, err => {
|
|
1806
1806
|
if (err) return cb(err)
|
|
1807
|
-
return fs$
|
|
1807
|
+
return fs$c.symlink(resolvedSrc, dest, cb)
|
|
1808
1808
|
});
|
|
1809
1809
|
}
|
|
1810
1810
|
|
|
1811
1811
|
// return true if dest is a subdir of src, otherwise false.
|
|
1812
1812
|
// extract dest base dir and check if that is the same as src basename.
|
|
1813
1813
|
function isSrcSubdir$2 (src, dest) {
|
|
1814
|
-
const srcArray = path$
|
|
1815
|
-
const destArray = path$
|
|
1814
|
+
const srcArray = path$c.resolve(src).split(path$c.sep);
|
|
1815
|
+
const destArray = path$c.resolve(dest).split(path$c.sep);
|
|
1816
1816
|
|
|
1817
1817
|
return srcArray.reduce((acc, current, i) => {
|
|
1818
1818
|
return acc && destArray[i] === current
|
|
@@ -1821,7 +1821,7 @@ function isSrcSubdir$2 (src, dest) {
|
|
|
1821
1821
|
|
|
1822
1822
|
// check if dest exists and is a symlink.
|
|
1823
1823
|
function checkDest (dest, cb) {
|
|
1824
|
-
fs$
|
|
1824
|
+
fs$c.readlink(dest, (err, resolvedPath) => {
|
|
1825
1825
|
if (err) {
|
|
1826
1826
|
if (err.code === 'ENOENT') return cb(null, notExist)
|
|
1827
1827
|
|
|
@@ -1836,8 +1836,8 @@ function checkDest (dest, cb) {
|
|
|
1836
1836
|
|
|
1837
1837
|
function pathsAreIdentical (src, dest) {
|
|
1838
1838
|
const os = process.platform;
|
|
1839
|
-
const resolvedSrc = path$
|
|
1840
|
-
const resolvedDest = path$
|
|
1839
|
+
const resolvedSrc = path$c.resolve(src);
|
|
1840
|
+
const resolvedDest = path$c.resolve(dest);
|
|
1841
1841
|
// case-insensitive paths
|
|
1842
1842
|
if (os === 'darwin' || os === 'win32') {
|
|
1843
1843
|
return resolvedSrc.toLowerCase() === resolvedDest.toLowerCase()
|
|
@@ -1866,8 +1866,8 @@ var copy$1 = {
|
|
|
1866
1866
|
copy: u$9(copy_1)
|
|
1867
1867
|
};
|
|
1868
1868
|
|
|
1869
|
-
const fs$
|
|
1870
|
-
const path$
|
|
1869
|
+
const fs$b = gracefulFs;
|
|
1870
|
+
const path$b = path__default["default"];
|
|
1871
1871
|
const assert = assert__default["default"];
|
|
1872
1872
|
|
|
1873
1873
|
const isWindows = (process.platform === 'win32');
|
|
@@ -1882,9 +1882,9 @@ function defaults (options) {
|
|
|
1882
1882
|
'readdir'
|
|
1883
1883
|
];
|
|
1884
1884
|
methods.forEach(m => {
|
|
1885
|
-
options[m] = options[m] || fs$
|
|
1885
|
+
options[m] = options[m] || fs$b[m];
|
|
1886
1886
|
m = m + 'Sync';
|
|
1887
|
-
options[m] = options[m] || fs$
|
|
1887
|
+
options[m] = options[m] || fs$b[m];
|
|
1888
1888
|
});
|
|
1889
1889
|
|
|
1890
1890
|
options.maxBusyTries = options.maxBusyTries || 3;
|
|
@@ -2072,7 +2072,7 @@ function rmkids (p, options, cb) {
|
|
|
2072
2072
|
if (n === 0) return options.rmdir(p, cb)
|
|
2073
2073
|
|
|
2074
2074
|
files.forEach(f => {
|
|
2075
|
-
rimraf$1(path$
|
|
2075
|
+
rimraf$1(path$b.join(p, f), options, er => {
|
|
2076
2076
|
if (errState) {
|
|
2077
2077
|
return
|
|
2078
2078
|
}
|
|
@@ -2154,7 +2154,7 @@ function rmdirSync (p, options, originalEr) {
|
|
|
2154
2154
|
function rmkidsSync (p, options) {
|
|
2155
2155
|
assert(p);
|
|
2156
2156
|
assert(options);
|
|
2157
|
-
options.readdirSync(p).forEach(f => rimrafSync(path$
|
|
2157
|
+
options.readdirSync(p).forEach(f => rimrafSync(path$b.join(p, f), options));
|
|
2158
2158
|
|
|
2159
2159
|
// We only end up here once we got ENOTEMPTY at least once, and
|
|
2160
2160
|
// at this point, we are guaranteed to have removed all the kids.
|
|
@@ -2188,17 +2188,17 @@ var remove$2 = {
|
|
|
2188
2188
|
};
|
|
2189
2189
|
|
|
2190
2190
|
const u$7 = universalify.fromCallback;
|
|
2191
|
-
const fs$
|
|
2192
|
-
const path$
|
|
2191
|
+
const fs$a = require$$1__default["default"];
|
|
2192
|
+
const path$a = path__default["default"];
|
|
2193
2193
|
const mkdir$5 = mkdirs_1;
|
|
2194
2194
|
const remove$1 = remove$2;
|
|
2195
2195
|
|
|
2196
2196
|
const emptyDir = u$7(function emptyDir (dir, callback) {
|
|
2197
2197
|
callback = callback || function () {};
|
|
2198
|
-
fs$
|
|
2198
|
+
fs$a.readdir(dir, (err, items) => {
|
|
2199
2199
|
if (err) return mkdir$5.mkdirs(dir, callback)
|
|
2200
2200
|
|
|
2201
|
-
items = items.map(item => path$
|
|
2201
|
+
items = items.map(item => path$a.join(dir, item));
|
|
2202
2202
|
|
|
2203
2203
|
deleteItem();
|
|
2204
2204
|
|
|
@@ -2216,13 +2216,13 @@ const emptyDir = u$7(function emptyDir (dir, callback) {
|
|
|
2216
2216
|
function emptyDirSync (dir) {
|
|
2217
2217
|
let items;
|
|
2218
2218
|
try {
|
|
2219
|
-
items = fs$
|
|
2219
|
+
items = fs$a.readdirSync(dir);
|
|
2220
2220
|
} catch (err) {
|
|
2221
2221
|
return mkdir$5.mkdirsSync(dir)
|
|
2222
2222
|
}
|
|
2223
2223
|
|
|
2224
2224
|
items.forEach(item => {
|
|
2225
|
-
item = path$
|
|
2225
|
+
item = path$a.join(dir, item);
|
|
2226
2226
|
remove$1.removeSync(item);
|
|
2227
2227
|
});
|
|
2228
2228
|
}
|
|
@@ -2235,22 +2235,22 @@ var empty = {
|
|
|
2235
2235
|
};
|
|
2236
2236
|
|
|
2237
2237
|
const u$6 = universalify.fromCallback;
|
|
2238
|
-
const path$
|
|
2239
|
-
const fs$
|
|
2238
|
+
const path$9 = path__default["default"];
|
|
2239
|
+
const fs$9 = gracefulFs;
|
|
2240
2240
|
const mkdir$4 = mkdirs_1;
|
|
2241
2241
|
const pathExists$6 = pathExists_1.pathExists;
|
|
2242
2242
|
|
|
2243
2243
|
function createFile (file, callback) {
|
|
2244
2244
|
function makeFile () {
|
|
2245
|
-
fs$
|
|
2245
|
+
fs$9.writeFile(file, '', err => {
|
|
2246
2246
|
if (err) return callback(err)
|
|
2247
2247
|
callback();
|
|
2248
2248
|
});
|
|
2249
2249
|
}
|
|
2250
2250
|
|
|
2251
|
-
fs$
|
|
2251
|
+
fs$9.stat(file, (err, stats) => { // eslint-disable-line handle-callback-err
|
|
2252
2252
|
if (!err && stats.isFile()) return callback()
|
|
2253
|
-
const dir = path$
|
|
2253
|
+
const dir = path$9.dirname(file);
|
|
2254
2254
|
pathExists$6(dir, (err, dirExists) => {
|
|
2255
2255
|
if (err) return callback(err)
|
|
2256
2256
|
if (dirExists) return makeFile()
|
|
@@ -2265,16 +2265,16 @@ function createFile (file, callback) {
|
|
|
2265
2265
|
function createFileSync (file) {
|
|
2266
2266
|
let stats;
|
|
2267
2267
|
try {
|
|
2268
|
-
stats = fs$
|
|
2268
|
+
stats = fs$9.statSync(file);
|
|
2269
2269
|
} catch (e) {}
|
|
2270
2270
|
if (stats && stats.isFile()) return
|
|
2271
2271
|
|
|
2272
|
-
const dir = path$
|
|
2273
|
-
if (!fs$
|
|
2272
|
+
const dir = path$9.dirname(file);
|
|
2273
|
+
if (!fs$9.existsSync(dir)) {
|
|
2274
2274
|
mkdir$4.mkdirsSync(dir);
|
|
2275
2275
|
}
|
|
2276
2276
|
|
|
2277
|
-
fs$
|
|
2277
|
+
fs$9.writeFileSync(file, '');
|
|
2278
2278
|
}
|
|
2279
2279
|
|
|
2280
2280
|
var file$1 = {
|
|
@@ -2283,14 +2283,14 @@ var file$1 = {
|
|
|
2283
2283
|
};
|
|
2284
2284
|
|
|
2285
2285
|
const u$5 = universalify.fromCallback;
|
|
2286
|
-
const path$
|
|
2287
|
-
const fs$
|
|
2286
|
+
const path$8 = path__default["default"];
|
|
2287
|
+
const fs$8 = gracefulFs;
|
|
2288
2288
|
const mkdir$3 = mkdirs_1;
|
|
2289
2289
|
const pathExists$5 = pathExists_1.pathExists;
|
|
2290
2290
|
|
|
2291
2291
|
function createLink (srcpath, dstpath, callback) {
|
|
2292
2292
|
function makeLink (srcpath, dstpath) {
|
|
2293
|
-
fs$
|
|
2293
|
+
fs$8.link(srcpath, dstpath, err => {
|
|
2294
2294
|
if (err) return callback(err)
|
|
2295
2295
|
callback(null);
|
|
2296
2296
|
});
|
|
@@ -2299,13 +2299,13 @@ function createLink (srcpath, dstpath, callback) {
|
|
|
2299
2299
|
pathExists$5(dstpath, (err, destinationExists) => {
|
|
2300
2300
|
if (err) return callback(err)
|
|
2301
2301
|
if (destinationExists) return callback(null)
|
|
2302
|
-
fs$
|
|
2302
|
+
fs$8.lstat(srcpath, (err) => {
|
|
2303
2303
|
if (err) {
|
|
2304
2304
|
err.message = err.message.replace('lstat', 'ensureLink');
|
|
2305
2305
|
return callback(err)
|
|
2306
2306
|
}
|
|
2307
2307
|
|
|
2308
|
-
const dir = path$
|
|
2308
|
+
const dir = path$8.dirname(dstpath);
|
|
2309
2309
|
pathExists$5(dir, (err, dirExists) => {
|
|
2310
2310
|
if (err) return callback(err)
|
|
2311
2311
|
if (dirExists) return makeLink(srcpath, dstpath)
|
|
@@ -2319,22 +2319,22 @@ function createLink (srcpath, dstpath, callback) {
|
|
|
2319
2319
|
}
|
|
2320
2320
|
|
|
2321
2321
|
function createLinkSync (srcpath, dstpath) {
|
|
2322
|
-
const destinationExists = fs$
|
|
2322
|
+
const destinationExists = fs$8.existsSync(dstpath);
|
|
2323
2323
|
if (destinationExists) return undefined
|
|
2324
2324
|
|
|
2325
2325
|
try {
|
|
2326
|
-
fs$
|
|
2326
|
+
fs$8.lstatSync(srcpath);
|
|
2327
2327
|
} catch (err) {
|
|
2328
2328
|
err.message = err.message.replace('lstat', 'ensureLink');
|
|
2329
2329
|
throw err
|
|
2330
2330
|
}
|
|
2331
2331
|
|
|
2332
|
-
const dir = path$
|
|
2333
|
-
const dirExists = fs$
|
|
2334
|
-
if (dirExists) return fs$
|
|
2332
|
+
const dir = path$8.dirname(dstpath);
|
|
2333
|
+
const dirExists = fs$8.existsSync(dir);
|
|
2334
|
+
if (dirExists) return fs$8.linkSync(srcpath, dstpath)
|
|
2335
2335
|
mkdir$3.mkdirsSync(dir);
|
|
2336
2336
|
|
|
2337
|
-
return fs$
|
|
2337
|
+
return fs$8.linkSync(srcpath, dstpath)
|
|
2338
2338
|
}
|
|
2339
2339
|
|
|
2340
2340
|
var link$1 = {
|
|
@@ -2342,8 +2342,8 @@ var link$1 = {
|
|
|
2342
2342
|
createLinkSync
|
|
2343
2343
|
};
|
|
2344
2344
|
|
|
2345
|
-
const path$
|
|
2346
|
-
const fs$
|
|
2345
|
+
const path$7 = path__default["default"];
|
|
2346
|
+
const fs$7 = gracefulFs;
|
|
2347
2347
|
const pathExists$4 = pathExists_1.pathExists;
|
|
2348
2348
|
|
|
2349
2349
|
/**
|
|
@@ -2369,8 +2369,8 @@ const pathExists$4 = pathExists_1.pathExists;
|
|
|
2369
2369
|
*/
|
|
2370
2370
|
|
|
2371
2371
|
function symlinkPaths$1 (srcpath, dstpath, callback) {
|
|
2372
|
-
if (path$
|
|
2373
|
-
return fs$
|
|
2372
|
+
if (path$7.isAbsolute(srcpath)) {
|
|
2373
|
+
return fs$7.lstat(srcpath, (err) => {
|
|
2374
2374
|
if (err) {
|
|
2375
2375
|
err.message = err.message.replace('lstat', 'ensureSymlink');
|
|
2376
2376
|
return callback(err)
|
|
@@ -2381,8 +2381,8 @@ function symlinkPaths$1 (srcpath, dstpath, callback) {
|
|
|
2381
2381
|
})
|
|
2382
2382
|
})
|
|
2383
2383
|
} else {
|
|
2384
|
-
const dstdir = path$
|
|
2385
|
-
const relativeToDst = path$
|
|
2384
|
+
const dstdir = path$7.dirname(dstpath);
|
|
2385
|
+
const relativeToDst = path$7.join(dstdir, srcpath);
|
|
2386
2386
|
return pathExists$4(relativeToDst, (err, exists) => {
|
|
2387
2387
|
if (err) return callback(err)
|
|
2388
2388
|
if (exists) {
|
|
@@ -2391,14 +2391,14 @@ function symlinkPaths$1 (srcpath, dstpath, callback) {
|
|
|
2391
2391
|
'toDst': srcpath
|
|
2392
2392
|
})
|
|
2393
2393
|
} else {
|
|
2394
|
-
return fs$
|
|
2394
|
+
return fs$7.lstat(srcpath, (err) => {
|
|
2395
2395
|
if (err) {
|
|
2396
2396
|
err.message = err.message.replace('lstat', 'ensureSymlink');
|
|
2397
2397
|
return callback(err)
|
|
2398
2398
|
}
|
|
2399
2399
|
return callback(null, {
|
|
2400
2400
|
'toCwd': srcpath,
|
|
2401
|
-
'toDst': path$
|
|
2401
|
+
'toDst': path$7.relative(dstdir, srcpath)
|
|
2402
2402
|
})
|
|
2403
2403
|
})
|
|
2404
2404
|
}
|
|
@@ -2408,28 +2408,28 @@ function symlinkPaths$1 (srcpath, dstpath, callback) {
|
|
|
2408
2408
|
|
|
2409
2409
|
function symlinkPathsSync$1 (srcpath, dstpath) {
|
|
2410
2410
|
let exists;
|
|
2411
|
-
if (path$
|
|
2412
|
-
exists = fs$
|
|
2411
|
+
if (path$7.isAbsolute(srcpath)) {
|
|
2412
|
+
exists = fs$7.existsSync(srcpath);
|
|
2413
2413
|
if (!exists) throw new Error('absolute srcpath does not exist')
|
|
2414
2414
|
return {
|
|
2415
2415
|
'toCwd': srcpath,
|
|
2416
2416
|
'toDst': srcpath
|
|
2417
2417
|
}
|
|
2418
2418
|
} else {
|
|
2419
|
-
const dstdir = path$
|
|
2420
|
-
const relativeToDst = path$
|
|
2421
|
-
exists = fs$
|
|
2419
|
+
const dstdir = path$7.dirname(dstpath);
|
|
2420
|
+
const relativeToDst = path$7.join(dstdir, srcpath);
|
|
2421
|
+
exists = fs$7.existsSync(relativeToDst);
|
|
2422
2422
|
if (exists) {
|
|
2423
2423
|
return {
|
|
2424
2424
|
'toCwd': relativeToDst,
|
|
2425
2425
|
'toDst': srcpath
|
|
2426
2426
|
}
|
|
2427
2427
|
} else {
|
|
2428
|
-
exists = fs$
|
|
2428
|
+
exists = fs$7.existsSync(srcpath);
|
|
2429
2429
|
if (!exists) throw new Error('relative srcpath does not exist')
|
|
2430
2430
|
return {
|
|
2431
2431
|
'toCwd': srcpath,
|
|
2432
|
-
'toDst': path$
|
|
2432
|
+
'toDst': path$7.relative(dstdir, srcpath)
|
|
2433
2433
|
}
|
|
2434
2434
|
}
|
|
2435
2435
|
}
|
|
@@ -2440,13 +2440,13 @@ var symlinkPaths_1 = {
|
|
|
2440
2440
|
symlinkPathsSync: symlinkPathsSync$1
|
|
2441
2441
|
};
|
|
2442
2442
|
|
|
2443
|
-
const fs$
|
|
2443
|
+
const fs$6 = gracefulFs;
|
|
2444
2444
|
|
|
2445
2445
|
function symlinkType$1 (srcpath, type, callback) {
|
|
2446
2446
|
callback = (typeof type === 'function') ? type : callback;
|
|
2447
2447
|
type = (typeof type === 'function') ? false : type;
|
|
2448
2448
|
if (type) return callback(null, type)
|
|
2449
|
-
fs$
|
|
2449
|
+
fs$6.lstat(srcpath, (err, stats) => {
|
|
2450
2450
|
if (err) return callback(null, 'file')
|
|
2451
2451
|
type = (stats && stats.isDirectory()) ? 'dir' : 'file';
|
|
2452
2452
|
callback(null, type);
|
|
@@ -2458,7 +2458,7 @@ function symlinkTypeSync$1 (srcpath, type) {
|
|
|
2458
2458
|
|
|
2459
2459
|
if (type) return type
|
|
2460
2460
|
try {
|
|
2461
|
-
stats = fs$
|
|
2461
|
+
stats = fs$6.lstatSync(srcpath);
|
|
2462
2462
|
} catch (e) {
|
|
2463
2463
|
return 'file'
|
|
2464
2464
|
}
|
|
@@ -2471,8 +2471,8 @@ var symlinkType_1 = {
|
|
|
2471
2471
|
};
|
|
2472
2472
|
|
|
2473
2473
|
const u$4 = universalify.fromCallback;
|
|
2474
|
-
const path$
|
|
2475
|
-
const fs$
|
|
2474
|
+
const path$6 = path__default["default"];
|
|
2475
|
+
const fs$5 = gracefulFs;
|
|
2476
2476
|
const _mkdirs = mkdirs_1;
|
|
2477
2477
|
const mkdirs = _mkdirs.mkdirs;
|
|
2478
2478
|
const mkdirsSync = _mkdirs.mkdirsSync;
|
|
@@ -2499,13 +2499,13 @@ function createSymlink (srcpath, dstpath, type, callback) {
|
|
|
2499
2499
|
srcpath = relative.toDst;
|
|
2500
2500
|
symlinkType(relative.toCwd, type, (err, type) => {
|
|
2501
2501
|
if (err) return callback(err)
|
|
2502
|
-
const dir = path$
|
|
2502
|
+
const dir = path$6.dirname(dstpath);
|
|
2503
2503
|
pathExists$3(dir, (err, dirExists) => {
|
|
2504
2504
|
if (err) return callback(err)
|
|
2505
|
-
if (dirExists) return fs$
|
|
2505
|
+
if (dirExists) return fs$5.symlink(srcpath, dstpath, type, callback)
|
|
2506
2506
|
mkdirs(dir, err => {
|
|
2507
2507
|
if (err) return callback(err)
|
|
2508
|
-
fs$
|
|
2508
|
+
fs$5.symlink(srcpath, dstpath, type, callback);
|
|
2509
2509
|
});
|
|
2510
2510
|
});
|
|
2511
2511
|
});
|
|
@@ -2514,17 +2514,17 @@ function createSymlink (srcpath, dstpath, type, callback) {
|
|
|
2514
2514
|
}
|
|
2515
2515
|
|
|
2516
2516
|
function createSymlinkSync (srcpath, dstpath, type) {
|
|
2517
|
-
const destinationExists = fs$
|
|
2517
|
+
const destinationExists = fs$5.existsSync(dstpath);
|
|
2518
2518
|
if (destinationExists) return undefined
|
|
2519
2519
|
|
|
2520
2520
|
const relative = symlinkPathsSync(srcpath, dstpath);
|
|
2521
2521
|
srcpath = relative.toDst;
|
|
2522
2522
|
type = symlinkTypeSync(relative.toCwd, type);
|
|
2523
|
-
const dir = path$
|
|
2524
|
-
const exists = fs$
|
|
2525
|
-
if (exists) return fs$
|
|
2523
|
+
const dir = path$6.dirname(dstpath);
|
|
2524
|
+
const exists = fs$5.existsSync(dir);
|
|
2525
|
+
if (exists) return fs$5.symlinkSync(srcpath, dstpath, type)
|
|
2526
2526
|
mkdirsSync(dir);
|
|
2527
|
-
return fs$
|
|
2527
|
+
return fs$5.symlinkSync(srcpath, dstpath, type)
|
|
2528
2528
|
}
|
|
2529
2529
|
|
|
2530
2530
|
var symlink$1 = {
|
|
@@ -2700,7 +2700,7 @@ var jsonfile = {
|
|
|
2700
2700
|
writeJsonSync: jsonFile$3.writeFileSync
|
|
2701
2701
|
};
|
|
2702
2702
|
|
|
2703
|
-
const path$
|
|
2703
|
+
const path$5 = path__default["default"];
|
|
2704
2704
|
const mkdir$2 = mkdirs_1;
|
|
2705
2705
|
const pathExists$2 = pathExists_1.pathExists;
|
|
2706
2706
|
const jsonFile$2 = jsonfile;
|
|
@@ -2711,7 +2711,7 @@ function outputJson (file, data, options, callback) {
|
|
|
2711
2711
|
options = {};
|
|
2712
2712
|
}
|
|
2713
2713
|
|
|
2714
|
-
const dir = path$
|
|
2714
|
+
const dir = path$5.dirname(file);
|
|
2715
2715
|
|
|
2716
2716
|
pathExists$2(dir, (err, itDoes) => {
|
|
2717
2717
|
if (err) return callback(err)
|
|
@@ -2726,15 +2726,15 @@ function outputJson (file, data, options, callback) {
|
|
|
2726
2726
|
|
|
2727
2727
|
var outputJson_1 = outputJson;
|
|
2728
2728
|
|
|
2729
|
-
const fs$
|
|
2730
|
-
const path$
|
|
2729
|
+
const fs$4 = gracefulFs;
|
|
2730
|
+
const path$4 = path__default["default"];
|
|
2731
2731
|
const mkdir$1 = mkdirs_1;
|
|
2732
2732
|
const jsonFile$1 = jsonfile;
|
|
2733
2733
|
|
|
2734
2734
|
function outputJsonSync (file, data, options) {
|
|
2735
|
-
const dir = path$
|
|
2735
|
+
const dir = path$4.dirname(file);
|
|
2736
2736
|
|
|
2737
|
-
if (!fs$
|
|
2737
|
+
if (!fs$4.existsSync(dir)) {
|
|
2738
2738
|
mkdir$1.mkdirsSync(dir);
|
|
2739
2739
|
}
|
|
2740
2740
|
|
|
@@ -2758,8 +2758,8 @@ jsonFile.readJSONSync = jsonFile.readJsonSync;
|
|
|
2758
2758
|
|
|
2759
2759
|
var json = jsonFile;
|
|
2760
2760
|
|
|
2761
|
-
const fs$
|
|
2762
|
-
const path$
|
|
2761
|
+
const fs$3 = gracefulFs;
|
|
2762
|
+
const path$3 = path__default["default"];
|
|
2763
2763
|
const copySync = copySync$1.copySync;
|
|
2764
2764
|
const removeSync = remove$2.removeSync;
|
|
2765
2765
|
const mkdirpSync = mkdirs_1.mkdirsSync;
|
|
@@ -2769,20 +2769,20 @@ function moveSync (src, dest, options) {
|
|
|
2769
2769
|
options = options || {};
|
|
2770
2770
|
const overwrite = options.overwrite || options.clobber || false;
|
|
2771
2771
|
|
|
2772
|
-
src = path$
|
|
2773
|
-
dest = path$
|
|
2772
|
+
src = path$3.resolve(src);
|
|
2773
|
+
dest = path$3.resolve(dest);
|
|
2774
2774
|
|
|
2775
|
-
if (src === dest) return fs$
|
|
2775
|
+
if (src === dest) return fs$3.accessSync(src)
|
|
2776
2776
|
|
|
2777
2777
|
if (isSrcSubdir$1(src, dest)) throw new Error(`Cannot move '${src}' into itself '${dest}'.`)
|
|
2778
2778
|
|
|
2779
|
-
mkdirpSync(path$
|
|
2779
|
+
mkdirpSync(path$3.dirname(dest));
|
|
2780
2780
|
tryRenameSync();
|
|
2781
2781
|
|
|
2782
2782
|
function tryRenameSync () {
|
|
2783
2783
|
if (overwrite) {
|
|
2784
2784
|
try {
|
|
2785
|
-
return fs$
|
|
2785
|
+
return fs$3.renameSync(src, dest)
|
|
2786
2786
|
} catch (err) {
|
|
2787
2787
|
if (err.code === 'ENOTEMPTY' || err.code === 'EEXIST' || err.code === 'EPERM') {
|
|
2788
2788
|
removeSync(dest);
|
|
@@ -2795,8 +2795,8 @@ function moveSync (src, dest, options) {
|
|
|
2795
2795
|
}
|
|
2796
2796
|
} else {
|
|
2797
2797
|
try {
|
|
2798
|
-
fs$
|
|
2799
|
-
return fs$
|
|
2798
|
+
fs$3.linkSync(src, dest);
|
|
2799
|
+
return fs$3.unlinkSync(src)
|
|
2800
2800
|
} catch (err) {
|
|
2801
2801
|
if (err.code === 'EXDEV' || err.code === 'EISDIR' || err.code === 'EPERM' || err.code === 'ENOTSUP') {
|
|
2802
2802
|
return moveSyncAcrossDevice(src, dest, overwrite)
|
|
@@ -2808,7 +2808,7 @@ function moveSync (src, dest, options) {
|
|
|
2808
2808
|
}
|
|
2809
2809
|
|
|
2810
2810
|
function moveSyncAcrossDevice (src, dest, overwrite) {
|
|
2811
|
-
const stat = fs$
|
|
2811
|
+
const stat = fs$3.statSync(src);
|
|
2812
2812
|
|
|
2813
2813
|
if (stat.isDirectory()) {
|
|
2814
2814
|
return moveDirSyncAcrossDevice(src, dest, overwrite)
|
|
@@ -2823,20 +2823,20 @@ function moveFileSyncAcrossDevice (src, dest, overwrite) {
|
|
|
2823
2823
|
|
|
2824
2824
|
const flags = overwrite ? 'w' : 'wx';
|
|
2825
2825
|
|
|
2826
|
-
const fdr = fs$
|
|
2827
|
-
const stat = fs$
|
|
2828
|
-
const fdw = fs$
|
|
2826
|
+
const fdr = fs$3.openSync(src, 'r');
|
|
2827
|
+
const stat = fs$3.fstatSync(fdr);
|
|
2828
|
+
const fdw = fs$3.openSync(dest, flags, stat.mode);
|
|
2829
2829
|
let pos = 0;
|
|
2830
2830
|
|
|
2831
2831
|
while (pos < stat.size) {
|
|
2832
|
-
const bytesRead = fs$
|
|
2833
|
-
fs$
|
|
2832
|
+
const bytesRead = fs$3.readSync(fdr, _buff, 0, BUF_LENGTH, pos);
|
|
2833
|
+
fs$3.writeSync(fdw, _buff, 0, bytesRead);
|
|
2834
2834
|
pos += bytesRead;
|
|
2835
2835
|
}
|
|
2836
2836
|
|
|
2837
|
-
fs$
|
|
2838
|
-
fs$
|
|
2839
|
-
return fs$
|
|
2837
|
+
fs$3.closeSync(fdr);
|
|
2838
|
+
fs$3.closeSync(fdw);
|
|
2839
|
+
return fs$3.unlinkSync(src)
|
|
2840
2840
|
}
|
|
2841
2841
|
|
|
2842
2842
|
function moveDirSyncAcrossDevice (src, dest, overwrite) {
|
|
@@ -2861,10 +2861,10 @@ function moveDirSyncAcrossDevice (src, dest, overwrite) {
|
|
|
2861
2861
|
// extract dest base dir and check if that is the same as src basename
|
|
2862
2862
|
function isSrcSubdir$1 (src, dest) {
|
|
2863
2863
|
try {
|
|
2864
|
-
return fs$
|
|
2864
|
+
return fs$3.statSync(src).isDirectory() &&
|
|
2865
2865
|
src !== dest &&
|
|
2866
2866
|
dest.indexOf(src) > -1 &&
|
|
2867
|
-
dest.split(path$
|
|
2867
|
+
dest.split(path$3.dirname(src) + path$3.sep)[1].split(path$3.sep)[0] === path$3.basename(src)
|
|
2868
2868
|
} catch (e) {
|
|
2869
2869
|
return false
|
|
2870
2870
|
}
|
|
@@ -2875,8 +2875,8 @@ var moveSync_1 = {
|
|
|
2875
2875
|
};
|
|
2876
2876
|
|
|
2877
2877
|
const u$1 = universalify.fromCallback;
|
|
2878
|
-
const fs$
|
|
2879
|
-
const path$
|
|
2878
|
+
const fs$2 = gracefulFs;
|
|
2879
|
+
const path$2 = path__default["default"];
|
|
2880
2880
|
const copy = copy$1.copy;
|
|
2881
2881
|
const remove = remove$2.remove;
|
|
2882
2882
|
const mkdirp = mkdirs_1.mkdirp;
|
|
@@ -2890,18 +2890,18 @@ function move (src, dest, opts, cb) {
|
|
|
2890
2890
|
|
|
2891
2891
|
const overwrite = opts.overwrite || opts.clobber || false;
|
|
2892
2892
|
|
|
2893
|
-
src = path$
|
|
2894
|
-
dest = path$
|
|
2893
|
+
src = path$2.resolve(src);
|
|
2894
|
+
dest = path$2.resolve(dest);
|
|
2895
2895
|
|
|
2896
|
-
if (src === dest) return fs$
|
|
2896
|
+
if (src === dest) return fs$2.access(src, cb)
|
|
2897
2897
|
|
|
2898
|
-
fs$
|
|
2898
|
+
fs$2.stat(src, (err, st) => {
|
|
2899
2899
|
if (err) return cb(err)
|
|
2900
2900
|
|
|
2901
2901
|
if (st.isDirectory() && isSrcSubdir(src, dest)) {
|
|
2902
2902
|
return cb(new Error(`Cannot move '${src}' to a subdirectory of itself, '${dest}'.`))
|
|
2903
2903
|
}
|
|
2904
|
-
mkdirp(path$
|
|
2904
|
+
mkdirp(path$2.dirname(dest), err => {
|
|
2905
2905
|
if (err) return cb(err)
|
|
2906
2906
|
return doRename(src, dest, overwrite, cb)
|
|
2907
2907
|
});
|
|
@@ -2923,7 +2923,7 @@ function doRename (src, dest, overwrite, cb) {
|
|
|
2923
2923
|
}
|
|
2924
2924
|
|
|
2925
2925
|
function rename (src, dest, overwrite, cb) {
|
|
2926
|
-
fs$
|
|
2926
|
+
fs$2.rename(src, dest, err => {
|
|
2927
2927
|
if (!err) return cb()
|
|
2928
2928
|
if (err.code !== 'EXDEV') return cb(err)
|
|
2929
2929
|
return moveAcrossDevice(src, dest, overwrite, cb)
|
|
@@ -2943,8 +2943,8 @@ function moveAcrossDevice (src, dest, overwrite, cb) {
|
|
|
2943
2943
|
}
|
|
2944
2944
|
|
|
2945
2945
|
function isSrcSubdir (src, dest) {
|
|
2946
|
-
const srcArray = src.split(path$
|
|
2947
|
-
const destArray = dest.split(path$
|
|
2946
|
+
const srcArray = src.split(path$2.sep);
|
|
2947
|
+
const destArray = dest.split(path$2.sep);
|
|
2948
2948
|
|
|
2949
2949
|
return srcArray.reduce((acc, current, i) => {
|
|
2950
2950
|
return acc && destArray[i] === current
|
|
@@ -2956,8 +2956,8 @@ var move_1 = {
|
|
|
2956
2956
|
};
|
|
2957
2957
|
|
|
2958
2958
|
const u = universalify.fromCallback;
|
|
2959
|
-
const fs$
|
|
2960
|
-
const path$
|
|
2959
|
+
const fs$1 = gracefulFs;
|
|
2960
|
+
const path$1 = path__default["default"];
|
|
2961
2961
|
const mkdir = mkdirs_1;
|
|
2962
2962
|
const pathExists = pathExists_1.pathExists;
|
|
2963
2963
|
|
|
@@ -2967,26 +2967,26 @@ function outputFile (file, data, encoding, callback) {
|
|
|
2967
2967
|
encoding = 'utf8';
|
|
2968
2968
|
}
|
|
2969
2969
|
|
|
2970
|
-
const dir = path$
|
|
2970
|
+
const dir = path$1.dirname(file);
|
|
2971
2971
|
pathExists(dir, (err, itDoes) => {
|
|
2972
2972
|
if (err) return callback(err)
|
|
2973
|
-
if (itDoes) return fs$
|
|
2973
|
+
if (itDoes) return fs$1.writeFile(file, data, encoding, callback)
|
|
2974
2974
|
|
|
2975
2975
|
mkdir.mkdirs(dir, err => {
|
|
2976
2976
|
if (err) return callback(err)
|
|
2977
2977
|
|
|
2978
|
-
fs$
|
|
2978
|
+
fs$1.writeFile(file, data, encoding, callback);
|
|
2979
2979
|
});
|
|
2980
2980
|
});
|
|
2981
2981
|
}
|
|
2982
2982
|
|
|
2983
2983
|
function outputFileSync (file, ...args) {
|
|
2984
|
-
const dir = path$
|
|
2985
|
-
if (fs$
|
|
2986
|
-
return fs$
|
|
2984
|
+
const dir = path$1.dirname(file);
|
|
2985
|
+
if (fs$1.existsSync(dir)) {
|
|
2986
|
+
return fs$1.writeFileSync(file, ...args)
|
|
2987
2987
|
}
|
|
2988
2988
|
mkdir.mkdirsSync(dir);
|
|
2989
|
-
fs$
|
|
2989
|
+
fs$1.writeFileSync(file, ...args);
|
|
2990
2990
|
}
|
|
2991
2991
|
|
|
2992
2992
|
var output = {
|
|
@@ -2999,7 +2999,7 @@ var output = {
|
|
|
2999
2999
|
module.exports = Object.assign(
|
|
3000
3000
|
{},
|
|
3001
3001
|
// Export promiseified graceful-fs:
|
|
3002
|
-
fs$
|
|
3002
|
+
fs$j,
|
|
3003
3003
|
// Export extra methods:
|
|
3004
3004
|
copySync$1,
|
|
3005
3005
|
copy$1,
|
|
@@ -3024,7 +3024,7 @@ var output = {
|
|
|
3024
3024
|
}
|
|
3025
3025
|
} (lib));
|
|
3026
3026
|
|
|
3027
|
-
var fs
|
|
3027
|
+
var fs = libExports;
|
|
3028
3028
|
|
|
3029
3029
|
class Compile extends EventEmitter__default["default"] {
|
|
3030
3030
|
constructor(args, argv0, dir, debug) {
|
|
@@ -3205,7 +3205,7 @@ class Compile extends EventEmitter__default["default"] {
|
|
|
3205
3205
|
if (debug) {
|
|
3206
3206
|
console.log("Calling", argv0, compiler, args.map((x) => '"' + x + '"').join(" "));
|
|
3207
3207
|
}
|
|
3208
|
-
if (!fs
|
|
3208
|
+
if (!fs.existsSync("/usr/bin/as")) {
|
|
3209
3209
|
this.emit("stderr", "as doesn't exist");
|
|
3210
3210
|
}
|
|
3211
3211
|
// const env = Object.assign({ TMPDIR: dir, TEMPDIR: dir, TEMP: dir }, process.env);
|
|
@@ -3229,13 +3229,13 @@ class Compile extends EventEmitter__default["default"] {
|
|
|
3229
3229
|
const files = [];
|
|
3230
3230
|
const addDir = (dir, prefix) => {
|
|
3231
3231
|
try {
|
|
3232
|
-
fs
|
|
3232
|
+
fs.readdirSync(dir).forEach((file) => {
|
|
3233
3233
|
if (file === "sourcefile") {
|
|
3234
3234
|
return;
|
|
3235
3235
|
}
|
|
3236
3236
|
try {
|
|
3237
3237
|
assert__default["default"](output !== undefined, "Must have output");
|
|
3238
|
-
const stat = fs
|
|
3238
|
+
const stat = fs.statSync(path__default["default"].join(dir, file));
|
|
3239
3239
|
if (stat.isDirectory()) {
|
|
3240
3240
|
addDir(path__default["default"].join(dir, file), prefix ? prefix + file + "/" : file + "/");
|
|
3241
3241
|
}
|
|
@@ -3312,309 +3312,6 @@ class Compile extends EventEmitter__default["default"] {
|
|
|
3312
3312
|
// });
|
|
3313
3313
|
module.exports = Compile;
|
|
3314
3314
|
|
|
3315
|
-
var posixExports = {};
|
|
3316
|
-
var posix$2 = {
|
|
3317
|
-
get exports(){ return posixExports; },
|
|
3318
|
-
set exports(v){ posixExports = v; },
|
|
3319
|
-
};
|
|
3320
|
-
|
|
3321
|
-
var path$1 = path__default["default"];
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
var IS_LINUX = require$$1__default$1["default"].platform() === 'linux';
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
// Attempt to load the bindings module from various possible locations
|
|
3328
|
-
function load_extension() {
|
|
3329
|
-
var ext_dirs = [
|
|
3330
|
-
'build/bindings', 'build/Release', 'out/Release', 'Release',
|
|
3331
|
-
'build/Debug', 'out/Debug',
|
|
3332
|
-
], i;
|
|
3333
|
-
for (i in ext_dirs) {
|
|
3334
|
-
try {
|
|
3335
|
-
return require(path$1.join(__dirname, '../..', ext_dirs[i],
|
|
3336
|
-
'posix.node'));
|
|
3337
|
-
|
|
3338
|
-
} catch (error) {
|
|
3339
|
-
if (!/Cannot find module/.test(error.message)) {
|
|
3340
|
-
throw error;
|
|
3341
|
-
}
|
|
3342
|
-
}
|
|
3343
|
-
}
|
|
3344
|
-
throw new Error("unable to load the node-posix extension module");
|
|
3345
|
-
}
|
|
3346
|
-
|
|
3347
|
-
var posix$1 = load_extension();
|
|
3348
|
-
|
|
3349
|
-
var syslog_constants = {};
|
|
3350
|
-
posix$1.update_syslog_constants(syslog_constants);
|
|
3351
|
-
|
|
3352
|
-
function syslog_const(value) {
|
|
3353
|
-
if (syslog_constants[value] === undefined) {
|
|
3354
|
-
throw new Error("invalid syslog constant value: " + value);
|
|
3355
|
-
}
|
|
3356
|
-
|
|
3357
|
-
return syslog_constants[value];
|
|
3358
|
-
}
|
|
3359
|
-
|
|
3360
|
-
function syslog_flags(option, prefix) {
|
|
3361
|
-
prefix = prefix || "";
|
|
3362
|
-
var opt = 0, key, flag;
|
|
3363
|
-
for (key in option) {
|
|
3364
|
-
flag = syslog_const(prefix + key); // checks all flags
|
|
3365
|
-
opt |= option[key] ? flag : 0;
|
|
3366
|
-
}
|
|
3367
|
-
return opt;
|
|
3368
|
-
}
|
|
3369
|
-
|
|
3370
|
-
posix$2.exports = {
|
|
3371
|
-
getgid: process.getgid,
|
|
3372
|
-
getuid: process.getuid,
|
|
3373
|
-
setgid: process.setgid,
|
|
3374
|
-
setuid: process.setuid,
|
|
3375
|
-
|
|
3376
|
-
chroot: posix$1.chroot,
|
|
3377
|
-
closelog: posix$1.closelog,
|
|
3378
|
-
getegid: posix$1.getegid,
|
|
3379
|
-
geteuid: posix$1.geteuid,
|
|
3380
|
-
getgrnam: posix$1.getgrnam,
|
|
3381
|
-
getpgid: posix$1.getpgid,
|
|
3382
|
-
setpgid: posix$1.setpgid,
|
|
3383
|
-
getppid: posix$1.getppid,
|
|
3384
|
-
getpwnam: posix$1.getpwnam,
|
|
3385
|
-
getrlimit: posix$1.getrlimit,
|
|
3386
|
-
setrlimit: posix$1.setrlimit,
|
|
3387
|
-
setsid: posix$1.setsid,
|
|
3388
|
-
|
|
3389
|
-
openlog: function (ident, option, facility) {
|
|
3390
|
-
return posix$1.openlog(ident, syslog_flags(option),
|
|
3391
|
-
syslog_const(facility));
|
|
3392
|
-
},
|
|
3393
|
-
|
|
3394
|
-
syslog: function (priority, message) {
|
|
3395
|
-
return posix$1.syslog(syslog_const(priority), message);
|
|
3396
|
-
},
|
|
3397
|
-
|
|
3398
|
-
setlogmask: function (maskpri) {
|
|
3399
|
-
var bits = posix$1.setlogmask(syslog_flags(maskpri, "mask_")), flags = {}, key;
|
|
3400
|
-
for (key in syslog_constants) {
|
|
3401
|
-
if (key.match("^mask_")) {
|
|
3402
|
-
flags[key.substr(5, 10)] = (bits & syslog_constants[key])
|
|
3403
|
-
? true : false;
|
|
3404
|
-
}
|
|
3405
|
-
}
|
|
3406
|
-
return flags;
|
|
3407
|
-
},
|
|
3408
|
-
|
|
3409
|
-
// http://pubs.opengroup.org/onlinepubs/007904875/functions/getpgrp.html
|
|
3410
|
-
getpgrp: function () {
|
|
3411
|
-
return posix$1.getpgid(0);
|
|
3412
|
-
},
|
|
3413
|
-
|
|
3414
|
-
seteuid: function (euid) {
|
|
3415
|
-
euid = (typeof (euid) === 'string') ? posix$1.getpwnam(euid).uid : euid;
|
|
3416
|
-
return posix$1.seteuid(euid);
|
|
3417
|
-
},
|
|
3418
|
-
|
|
3419
|
-
setreuid: function (ruid, euid) {
|
|
3420
|
-
ruid = (typeof (ruid) === 'string') ? posix$1.getpwnam(ruid).uid : ruid;
|
|
3421
|
-
euid = (typeof (euid) === 'string') ? posix$1.getpwnam(euid).uid : euid;
|
|
3422
|
-
return posix$1.setreuid(ruid, euid);
|
|
3423
|
-
},
|
|
3424
|
-
|
|
3425
|
-
setegid: function (egid) {
|
|
3426
|
-
egid = (typeof (egid) === 'string') ? posix$1.getgrnam(egid).gid : egid;
|
|
3427
|
-
return posix$1.setegid(egid);
|
|
3428
|
-
},
|
|
3429
|
-
|
|
3430
|
-
setregid: function (rgid, egid) {
|
|
3431
|
-
rgid = (typeof (rgid) === 'string') ? posix$1.getgrnam(rgid).gid : rgid;
|
|
3432
|
-
egid = (typeof (egid) === 'string') ? posix$1.getgrnam(egid).gid : egid;
|
|
3433
|
-
return posix$1.setregid(rgid, egid);
|
|
3434
|
-
},
|
|
3435
|
-
|
|
3436
|
-
gethostname: posix$1.gethostname,
|
|
3437
|
-
sethostname: posix$1.sethostname,
|
|
3438
|
-
};
|
|
3439
|
-
|
|
3440
|
-
var swap_constants = {};
|
|
3441
|
-
|
|
3442
|
-
function swap_const(value) {
|
|
3443
|
-
var constant = swap_constants[value];
|
|
3444
|
-
if (constant === undefined) {
|
|
3445
|
-
throw "invalid swap constant value: " + value;
|
|
3446
|
-
}
|
|
3447
|
-
|
|
3448
|
-
return constant;
|
|
3449
|
-
}
|
|
3450
|
-
|
|
3451
|
-
function swap_flags(option) {
|
|
3452
|
-
var opt = 0, key, flag;
|
|
3453
|
-
for (key in option) {
|
|
3454
|
-
flag = swap_const(key); // checks all flags
|
|
3455
|
-
opt |= option[key] ? flag : 0;
|
|
3456
|
-
}
|
|
3457
|
-
return opt;
|
|
3458
|
-
}
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
if (IS_LINUX) {
|
|
3462
|
-
posix$1.update_swap_constants(swap_constants);
|
|
3463
|
-
posixExports.swapon = function (path, swapflags) {
|
|
3464
|
-
return posix$1.swapon(path, swap_flags(swapflags));
|
|
3465
|
-
};
|
|
3466
|
-
posixExports.swapoff = posix$1.swapoff;
|
|
3467
|
-
}
|
|
3468
|
-
|
|
3469
|
-
if ('initgroups' in posix$1) {
|
|
3470
|
-
// initgroups is in SVr4 and 4.3BSD, not POSIX
|
|
3471
|
-
posixExports.initgroups = function (user, group) {
|
|
3472
|
-
var gid = (typeof (group) === 'string') ? posix$1.getgrnam(group).gid : group;
|
|
3473
|
-
return posix$1.initgroups(user, gid);
|
|
3474
|
-
};
|
|
3475
|
-
}
|
|
3476
|
-
|
|
3477
|
-
/**
|
|
3478
|
-
* Copyright (c) 2014, 2015, 2021 Tim Kuijsten
|
|
3479
|
-
*
|
|
3480
|
-
* Permission to use, copy, modify, and/or distribute this software for any
|
|
3481
|
-
* purpose with or without fee is hereby granted, provided that the above
|
|
3482
|
-
* copyright notice and this permission notice appear in all copies.
|
|
3483
|
-
*
|
|
3484
|
-
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
3485
|
-
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
3486
|
-
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
3487
|
-
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
3488
|
-
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
3489
|
-
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
3490
|
-
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
3491
|
-
*/
|
|
3492
|
-
|
|
3493
|
-
var fs = require$$1__default["default"];
|
|
3494
|
-
var path = path__default["default"];
|
|
3495
|
-
|
|
3496
|
-
var posix = posixExports;
|
|
3497
|
-
|
|
3498
|
-
/**
|
|
3499
|
-
* Change the root directory of the current process. A normal user must be provided
|
|
3500
|
-
* since changing root without dropping privileges makes no sense from a security
|
|
3501
|
-
* point of view.
|
|
3502
|
-
*
|
|
3503
|
-
* @param {String} newRoot The path to the new root directory for this process.
|
|
3504
|
-
* The whole path should be owned by the super user and may not be writable
|
|
3505
|
-
* by the group owner or others.
|
|
3506
|
-
* @param {String|Number} user The user to switch to after changing the root
|
|
3507
|
-
* directory. Can be either a name or an id.
|
|
3508
|
-
* @param {String|Number} [group] The group to switch to after changing the root
|
|
3509
|
-
* directory. Can be either a name or an id of any group the user belongs to
|
|
3510
|
-
* (see /etc/groups). Defaults to the users primary group (see /etc/passwd).
|
|
3511
|
-
* @throw if any operation fails
|
|
3512
|
-
*/
|
|
3513
|
-
var chroot = function chroot(newRoot, user, group) {
|
|
3514
|
-
if (typeof newRoot !== 'string') { throw new TypeError('newRoot must be a string'); }
|
|
3515
|
-
if (typeof user !== 'string' && typeof user !== 'number') { throw new TypeError('user must be a string or a number'); }
|
|
3516
|
-
if (typeof group !== 'undefined') {
|
|
3517
|
-
if (typeof group !== 'string' && typeof group !== 'number') { throw new TypeError('group must be a string or a number'); }
|
|
3518
|
-
}
|
|
3519
|
-
|
|
3520
|
-
if (!(newRoot.length > 0)) { throw new Error('newRoot must contain at least one character'); }
|
|
3521
|
-
if (typeof user === 'string' && !(user.length > 0)) { throw new Error('user must contain at least one character'); }
|
|
3522
|
-
|
|
3523
|
-
if (process.getuid() !== 0 || posix.geteuid() !== 0) {
|
|
3524
|
-
throw new Error('chroot must be called while running as root');
|
|
3525
|
-
}
|
|
3526
|
-
|
|
3527
|
-
var pwd, grp, uid, gid;
|
|
3528
|
-
|
|
3529
|
-
// resolve user to a numeric id
|
|
3530
|
-
try {
|
|
3531
|
-
pwd = posix.getpwnam(user);
|
|
3532
|
-
} catch(err) {
|
|
3533
|
-
throw new Error('user not found: ' + user);
|
|
3534
|
-
}
|
|
3535
|
-
|
|
3536
|
-
uid = pwd.uid;
|
|
3537
|
-
gid = pwd.gid;
|
|
3538
|
-
|
|
3539
|
-
if (typeof group !== 'undefined') {
|
|
3540
|
-
if (typeof group === 'number') {
|
|
3541
|
-
gid = group;
|
|
3542
|
-
} else {
|
|
3543
|
-
// resolve group to a numeric id
|
|
3544
|
-
try {
|
|
3545
|
-
grp = posix.getgrnam(group);
|
|
3546
|
-
} catch(err) {
|
|
3547
|
-
throw new Error('group not found: ' + group);
|
|
3548
|
-
}
|
|
3549
|
-
|
|
3550
|
-
gid = grp.gid;
|
|
3551
|
-
}
|
|
3552
|
-
}
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
if (typeof uid !== 'number') { throw new TypeError('could not resolve the user to a number'); }
|
|
3556
|
-
if (typeof gid !== 'number') { throw new TypeError('could not resolve the group to a number'); }
|
|
3557
|
-
|
|
3558
|
-
if (!(uid > 0)) { throw new Error('new user can not have user id 0'); }
|
|
3559
|
-
if (!(gid > 0)) { throw new Error('new group can not have group id 0'); }
|
|
3560
|
-
|
|
3561
|
-
// check permissions up to the original root of the file system
|
|
3562
|
-
var rpath = newRoot = fs.realpathSync(newRoot);
|
|
3563
|
-
|
|
3564
|
-
var stats;
|
|
3565
|
-
do {
|
|
3566
|
-
stats = fs.statSync(rpath);
|
|
3567
|
-
if (stats.uid !== 0 || (stats.mode & (fs.constants.S_IWGRP | fs.constants.S_IWOTH)) !== 0) {
|
|
3568
|
-
throw new Error('bad chroot dir ' + rpath + ' owner: ' + stats.uid + ' or permissions: 0' + stats.mode.toString(8));
|
|
3569
|
-
}
|
|
3570
|
-
rpath = path.dirname(rpath);
|
|
3571
|
-
} while (rpath !== '/');
|
|
3572
|
-
|
|
3573
|
-
try {
|
|
3574
|
-
posix.chroot(newRoot);
|
|
3575
|
-
} catch(err) {
|
|
3576
|
-
throw new Error('changing root failed: ' + err.message);
|
|
3577
|
-
}
|
|
3578
|
-
process.chdir('/');
|
|
3579
|
-
|
|
3580
|
-
// PWD might be set in some environments and is part of POSIX
|
|
3581
|
-
if (typeof process.env.PWD !== 'undefined') {
|
|
3582
|
-
process.env.PWD = '/';
|
|
3583
|
-
}
|
|
3584
|
-
|
|
3585
|
-
try {
|
|
3586
|
-
if (typeof group === 'undefined') {
|
|
3587
|
-
// change to the given user and all the groups that it is a member of
|
|
3588
|
-
process.initgroups(uid, gid);
|
|
3589
|
-
} else {
|
|
3590
|
-
// change to the given user and the given group (not all groups the user is member of)
|
|
3591
|
-
process.setgroups([gid]);
|
|
3592
|
-
}
|
|
3593
|
-
} catch(err) {
|
|
3594
|
-
throw new Error('changing groups failed: ' + err.message);
|
|
3595
|
-
}
|
|
3596
|
-
|
|
3597
|
-
process.setgid(gid);
|
|
3598
|
-
process.setuid(uid);
|
|
3599
|
-
|
|
3600
|
-
// try to restore privileges
|
|
3601
|
-
try {
|
|
3602
|
-
posix.setreuid(-1, 0);
|
|
3603
|
-
} catch(err) {
|
|
3604
|
-
// double check real and effective ids of the user and group and supplemental groups
|
|
3605
|
-
var ids = [process.getuid(), process.getgid(), posix.geteuid(), posix.getegid()];
|
|
3606
|
-
Array.prototype.push.apply(ids, process.getgroups());
|
|
3607
|
-
|
|
3608
|
-
// if none of the ids is zero, privileges are successfully dropped
|
|
3609
|
-
if (!~ids.indexOf(0)) {
|
|
3610
|
-
// success
|
|
3611
|
-
return;
|
|
3612
|
-
}
|
|
3613
|
-
}
|
|
3614
|
-
|
|
3615
|
-
throw new Error('unable to drop privileges');
|
|
3616
|
-
};
|
|
3617
|
-
|
|
3618
3315
|
var minimist = function (args, opts) {
|
|
3619
3316
|
if (!opts) opts = {};
|
|
3620
3317
|
|
|
@@ -3865,6 +3562,168 @@ function isConstructorOrProto (obj, key) {
|
|
|
3865
3562
|
return key === 'constructor' && typeof obj[key] === 'function' || key === '__proto__';
|
|
3866
3563
|
}
|
|
3867
3564
|
|
|
3565
|
+
var posixExports = {};
|
|
3566
|
+
var posix$1 = {
|
|
3567
|
+
get exports(){ return posixExports; },
|
|
3568
|
+
set exports(v){ posixExports = v; },
|
|
3569
|
+
};
|
|
3570
|
+
|
|
3571
|
+
var path = path__default["default"];
|
|
3572
|
+
|
|
3573
|
+
|
|
3574
|
+
var IS_LINUX = require$$1__default$1["default"].platform() === 'linux';
|
|
3575
|
+
|
|
3576
|
+
|
|
3577
|
+
// Attempt to load the bindings module from various possible locations
|
|
3578
|
+
function load_extension() {
|
|
3579
|
+
var ext_dirs = [
|
|
3580
|
+
'build/bindings', 'build/Release', 'out/Release', 'Release',
|
|
3581
|
+
'build/Debug', 'out/Debug',
|
|
3582
|
+
], i;
|
|
3583
|
+
for (i in ext_dirs) {
|
|
3584
|
+
try {
|
|
3585
|
+
return require(path.join(__dirname, '../..', ext_dirs[i],
|
|
3586
|
+
'posix.node'));
|
|
3587
|
+
|
|
3588
|
+
} catch (error) {
|
|
3589
|
+
if (!/Cannot find module/.test(error.message)) {
|
|
3590
|
+
throw error;
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
throw new Error("unable to load the node-posix extension module");
|
|
3595
|
+
}
|
|
3596
|
+
|
|
3597
|
+
var posix = load_extension();
|
|
3598
|
+
|
|
3599
|
+
var syslog_constants = {};
|
|
3600
|
+
posix.update_syslog_constants(syslog_constants);
|
|
3601
|
+
|
|
3602
|
+
function syslog_const(value) {
|
|
3603
|
+
if (syslog_constants[value] === undefined) {
|
|
3604
|
+
throw new Error("invalid syslog constant value: " + value);
|
|
3605
|
+
}
|
|
3606
|
+
|
|
3607
|
+
return syslog_constants[value];
|
|
3608
|
+
}
|
|
3609
|
+
|
|
3610
|
+
function syslog_flags(option, prefix) {
|
|
3611
|
+
prefix = prefix || "";
|
|
3612
|
+
var opt = 0, key, flag;
|
|
3613
|
+
for (key in option) {
|
|
3614
|
+
flag = syslog_const(prefix + key); // checks all flags
|
|
3615
|
+
opt |= option[key] ? flag : 0;
|
|
3616
|
+
}
|
|
3617
|
+
return opt;
|
|
3618
|
+
}
|
|
3619
|
+
|
|
3620
|
+
posix$1.exports = {
|
|
3621
|
+
getgid: process.getgid,
|
|
3622
|
+
getuid: process.getuid,
|
|
3623
|
+
setgid: process.setgid,
|
|
3624
|
+
setuid: process.setuid,
|
|
3625
|
+
|
|
3626
|
+
chroot: posix.chroot,
|
|
3627
|
+
closelog: posix.closelog,
|
|
3628
|
+
getegid: posix.getegid,
|
|
3629
|
+
geteuid: posix.geteuid,
|
|
3630
|
+
getgrnam: posix.getgrnam,
|
|
3631
|
+
getpgid: posix.getpgid,
|
|
3632
|
+
setpgid: posix.setpgid,
|
|
3633
|
+
getppid: posix.getppid,
|
|
3634
|
+
getpwnam: posix.getpwnam,
|
|
3635
|
+
getrlimit: posix.getrlimit,
|
|
3636
|
+
setrlimit: posix.setrlimit,
|
|
3637
|
+
setsid: posix.setsid,
|
|
3638
|
+
|
|
3639
|
+
openlog: function (ident, option, facility) {
|
|
3640
|
+
return posix.openlog(ident, syslog_flags(option),
|
|
3641
|
+
syslog_const(facility));
|
|
3642
|
+
},
|
|
3643
|
+
|
|
3644
|
+
syslog: function (priority, message) {
|
|
3645
|
+
return posix.syslog(syslog_const(priority), message);
|
|
3646
|
+
},
|
|
3647
|
+
|
|
3648
|
+
setlogmask: function (maskpri) {
|
|
3649
|
+
var bits = posix.setlogmask(syslog_flags(maskpri, "mask_")), flags = {}, key;
|
|
3650
|
+
for (key in syslog_constants) {
|
|
3651
|
+
if (key.match("^mask_")) {
|
|
3652
|
+
flags[key.substr(5, 10)] = (bits & syslog_constants[key])
|
|
3653
|
+
? true : false;
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3656
|
+
return flags;
|
|
3657
|
+
},
|
|
3658
|
+
|
|
3659
|
+
// http://pubs.opengroup.org/onlinepubs/007904875/functions/getpgrp.html
|
|
3660
|
+
getpgrp: function () {
|
|
3661
|
+
return posix.getpgid(0);
|
|
3662
|
+
},
|
|
3663
|
+
|
|
3664
|
+
seteuid: function (euid) {
|
|
3665
|
+
euid = (typeof (euid) === 'string') ? posix.getpwnam(euid).uid : euid;
|
|
3666
|
+
return posix.seteuid(euid);
|
|
3667
|
+
},
|
|
3668
|
+
|
|
3669
|
+
setreuid: function (ruid, euid) {
|
|
3670
|
+
ruid = (typeof (ruid) === 'string') ? posix.getpwnam(ruid).uid : ruid;
|
|
3671
|
+
euid = (typeof (euid) === 'string') ? posix.getpwnam(euid).uid : euid;
|
|
3672
|
+
return posix.setreuid(ruid, euid);
|
|
3673
|
+
},
|
|
3674
|
+
|
|
3675
|
+
setegid: function (egid) {
|
|
3676
|
+
egid = (typeof (egid) === 'string') ? posix.getgrnam(egid).gid : egid;
|
|
3677
|
+
return posix.setegid(egid);
|
|
3678
|
+
},
|
|
3679
|
+
|
|
3680
|
+
setregid: function (rgid, egid) {
|
|
3681
|
+
rgid = (typeof (rgid) === 'string') ? posix.getgrnam(rgid).gid : rgid;
|
|
3682
|
+
egid = (typeof (egid) === 'string') ? posix.getgrnam(egid).gid : egid;
|
|
3683
|
+
return posix.setregid(rgid, egid);
|
|
3684
|
+
},
|
|
3685
|
+
|
|
3686
|
+
gethostname: posix.gethostname,
|
|
3687
|
+
sethostname: posix.sethostname,
|
|
3688
|
+
};
|
|
3689
|
+
|
|
3690
|
+
var swap_constants = {};
|
|
3691
|
+
|
|
3692
|
+
function swap_const(value) {
|
|
3693
|
+
var constant = swap_constants[value];
|
|
3694
|
+
if (constant === undefined) {
|
|
3695
|
+
throw "invalid swap constant value: " + value;
|
|
3696
|
+
}
|
|
3697
|
+
|
|
3698
|
+
return constant;
|
|
3699
|
+
}
|
|
3700
|
+
|
|
3701
|
+
function swap_flags(option) {
|
|
3702
|
+
var opt = 0, key, flag;
|
|
3703
|
+
for (key in option) {
|
|
3704
|
+
flag = swap_const(key); // checks all flags
|
|
3705
|
+
opt |= option[key] ? flag : 0;
|
|
3706
|
+
}
|
|
3707
|
+
return opt;
|
|
3708
|
+
}
|
|
3709
|
+
|
|
3710
|
+
|
|
3711
|
+
if (IS_LINUX) {
|
|
3712
|
+
posix.update_swap_constants(swap_constants);
|
|
3713
|
+
posixExports.swapon = function (path, swapflags) {
|
|
3714
|
+
return posix.swapon(path, swap_flags(swapflags));
|
|
3715
|
+
};
|
|
3716
|
+
posixExports.swapoff = posix.swapoff;
|
|
3717
|
+
}
|
|
3718
|
+
|
|
3719
|
+
if ('initgroups' in posix) {
|
|
3720
|
+
// initgroups is in SVr4 and 4.3BSD, not POSIX
|
|
3721
|
+
posixExports.initgroups = function (user, group) {
|
|
3722
|
+
var gid = (typeof (group) === 'string') ? posix.getgrnam(group).gid : group;
|
|
3723
|
+
return posix.initgroups(user, gid);
|
|
3724
|
+
};
|
|
3725
|
+
}
|
|
3726
|
+
|
|
3868
3727
|
const argv = minimist(process.argv.slice(2));
|
|
3869
3728
|
function send(message) {
|
|
3870
3729
|
try {
|
|
@@ -3884,19 +3743,34 @@ process.on("uncaughtException", (err) => {
|
|
|
3884
3743
|
send({ type: "error", message: `Uncaught exception ${err.stack} ${err.toString()}` });
|
|
3885
3744
|
console.error("Uncaught exception", err);
|
|
3886
3745
|
});
|
|
3887
|
-
|
|
3746
|
+
let pwd;
|
|
3747
|
+
if (argv.user) {
|
|
3748
|
+
try {
|
|
3749
|
+
pwd = posixExports.getpwnam(argv.user);
|
|
3750
|
+
}
|
|
3751
|
+
catch (err) {
|
|
3752
|
+
console.error("Couldn't find user", argv.user);
|
|
3753
|
+
throw err;
|
|
3754
|
+
}
|
|
3755
|
+
try {
|
|
3756
|
+
process.initgroups(argv.user, pwd.gid);
|
|
3757
|
+
}
|
|
3758
|
+
catch (err) {
|
|
3759
|
+
throw new Error("Changing groups failed: " + err.message);
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3888
3762
|
try {
|
|
3889
3763
|
console.log("Chrooting to", argv.root);
|
|
3890
|
-
chroot(argv.root
|
|
3764
|
+
posixExports.chroot(argv.root);
|
|
3891
3765
|
}
|
|
3892
3766
|
catch (err) {
|
|
3893
3767
|
console.error("Changing root or user failed", err);
|
|
3894
3768
|
process.exit(1);
|
|
3895
3769
|
}
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3770
|
+
if (pwd) {
|
|
3771
|
+
process.setgid(pwd.gid);
|
|
3772
|
+
process.setuid(pwd.uid);
|
|
3773
|
+
}
|
|
3900
3774
|
process.on("error", (error) => {
|
|
3901
3775
|
console.error(`Got process error ${error} ${JSON.stringify(argv)}. Going down`);
|
|
3902
3776
|
process.exit();
|