extract-base-iterator 0.4.1 → 1.0.1
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/cjs/DirectoryEntry.js +33 -26
- package/dist/cjs/DirectoryEntry.js.map +1 -1
- package/dist/cjs/FileEntry.js +35 -28
- package/dist/cjs/FileEntry.js.map +1 -1
- package/dist/cjs/LinkEntry.js +39 -32
- package/dist/cjs/LinkEntry.js.map +1 -1
- package/dist/cjs/SymbolicLinkEntry.js +47 -40
- package/dist/cjs/SymbolicLinkEntry.js.map +1 -1
- package/dist/cjs/fs/chmod.js +19 -10
- package/dist/cjs/fs/chmod.js.map +1 -1
- package/dist/cjs/fs/chown.js +19 -10
- package/dist/cjs/fs/chown.js.map +1 -1
- package/dist/cjs/fs/lstatReal.js +20 -11
- package/dist/cjs/fs/lstatReal.js.map +1 -1
- package/dist/cjs/fs/utimes.js +19 -10
- package/dist/cjs/fs/utimes.js.map +1 -1
- package/dist/cjs/fs/waitForAccess.js +17 -9
- package/dist/cjs/fs/waitForAccess.js.map +1 -1
- package/dist/cjs/index.js +26 -17
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/polyfills.js +3 -0
- package/dist/cjs/polyfills.js.map +1 -0
- package/dist/cjs/stripPath.js +21 -12
- package/dist/cjs/stripPath.js.map +1 -1
- package/dist/cjs/validateAttributes.js +12 -8
- package/dist/cjs/validateAttributes.js.map +1 -1
- package/dist/esm/DirectoryEntry.mjs +48 -0
- package/dist/esm/DirectoryEntry.mjs.map +1 -0
- package/dist/esm/FileEntry.mjs +57 -0
- package/dist/esm/FileEntry.mjs.map +1 -0
- package/dist/esm/LinkEntry.mjs +60 -0
- package/dist/esm/LinkEntry.mjs.map +1 -0
- package/dist/esm/SymbolicLinkEntry.mjs +76 -0
- package/dist/esm/SymbolicLinkEntry.mjs.map +1 -0
- package/dist/esm/fs/chmod.mjs +29 -0
- package/dist/esm/fs/chmod.mjs.map +1 -0
- package/dist/esm/fs/chown.mjs +9 -0
- package/dist/esm/fs/chown.mjs.map +1 -0
- package/dist/esm/fs/lstatReal.mjs +6 -0
- package/dist/esm/fs/lstatReal.mjs.map +1 -0
- package/dist/esm/fs/utimes.mjs +6 -0
- package/dist/esm/fs/utimes.mjs.map +1 -0
- package/dist/esm/fs/waitForAccess.mjs +7 -0
- package/dist/esm/fs/waitForAccess.mjs.map +1 -0
- package/dist/esm/index.mjs +7 -0
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/polyfills.cjs +1 -0
- package/dist/esm/polyfills.cjs.map +1 -0
- package/dist/esm/stripPath.mjs +9 -0
- package/dist/esm/stripPath.mjs.map +1 -0
- package/dist/esm/validateAttributes.mjs +7 -0
- package/dist/esm/validateAttributes.mjs.map +1 -0
- package/dist/types/{DirectoryEntry.d.cts → DirectoryEntry.d.mts} +2 -3
- package/dist/types/{FileEntry.d.cts → FileEntry.d.mts} +2 -3
- package/dist/types/{LinkEntry.d.cts → LinkEntry.d.mts} +2 -3
- package/dist/types/{SymbolicLinkEntry.d.cts → SymbolicLinkEntry.d.mts} +2 -3
- package/dist/types/fs/chmod.d.mts +1 -0
- package/dist/types/fs/chown.d.mts +1 -0
- package/dist/types/fs/lstatReal.d.mts +1 -0
- package/dist/types/fs/utimes.d.mts +1 -0
- package/dist/types/fs/waitForAccess.d.mts +1 -0
- package/dist/types/index.d.mts +4 -0
- package/dist/types/polyfills.d.cts +1 -0
- package/dist/types/stripPath.d.mts +1 -0
- package/dist/types/validateAttributes.d.mts +1 -0
- package/package.json +19 -8
- package/dist/types/fs/chmod.d.ts +0 -2
- package/dist/types/fs/chown.d.ts +0 -2
- package/dist/types/fs/lstatReal.d.ts +0 -2
- package/dist/types/fs/utimes.d.ts +0 -2
- package/dist/types/fs/waitForAccess.d.ts +0 -2
- package/dist/types/stripPath.d.cts +0 -2
- package/dist/types/validateAttributes.d.cts +0 -2
package/dist/cjs/fs/chown.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
// adapted from https://github.com/mafintosh/tar-fs
|
|
2
2
|
"use strict";
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return chownFn;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _gracefulfs = /*#__PURE__*/ _interop_require_default(require("graceful-fs"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
4
18
|
var UID = process.getuid ? process.getuid() : -1;
|
|
5
19
|
var OWN = process.platform !== "win32" && UID === 0;
|
|
6
|
-
|
|
7
|
-
var chown = entry.type === "symlink" ?
|
|
20
|
+
function chownFn(fullPath, entry, _options, callback) {
|
|
21
|
+
var chown = entry.type === "symlink" ? _gracefulfs.default.lchown : _gracefulfs.default.chown;
|
|
8
22
|
if (!chown || !OWN || !entry.uid || !entry.gid) return callback();
|
|
9
23
|
chown(fullPath, entry.uid, entry.gid, callback);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
13
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
14
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
15
|
-
module.exports = exports.default;
|
|
16
|
-
}
|
|
24
|
+
}
|
|
25
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
package/dist/cjs/fs/chown.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["chown.
|
|
1
|
+
{"version":3,"sources":["chown.mjs"],"sourcesContent":["// adapted from https://github.com/mafintosh/tar-fs\n\nimport fs from 'graceful-fs';\n\nconst UID = process.getuid ? process.getuid() : -1;\nconst OWN = process.platform !== 'win32' && UID === 0;\n\nexport default function chownFn(fullPath, entry, _options, callback) {\n const chown = entry.type === 'symlink' ? fs.lchown : fs.chown;\n if (!chown || !OWN || !entry.uid || !entry.gid) return callback();\n chown(fullPath, entry.uid, entry.gid, callback);\n}\n"],"names":["chownFn","UID","process","getuid","OWN","platform","fullPath","entry","_options","callback","chown","type","fs","lchown","uid","gid"],"mappings":"AAAA,mDAAmD;;;;;+BAOnD;;;eAAwBA;;;iEALT;;;;;;AAEf,IAAMC,MAAMC,QAAQC,MAAM,GAAGD,QAAQC,MAAM,KAAK,CAAC;AACjD,IAAMC,MAAMF,QAAQG,QAAQ,KAAK,WAAWJ,QAAQ;AAErC,SAASD,QAAQM,QAAQ,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ;IACjE,IAAMC,QAAQH,MAAMI,IAAI,KAAK,YAAYC,mBAAE,CAACC,MAAM,GAAGD,mBAAE,CAACF,KAAK;IAC7D,IAAI,CAACA,SAAS,CAACN,OAAO,CAACG,MAAMO,GAAG,IAAI,CAACP,MAAMQ,GAAG,EAAE,OAAON;IACvDC,MAAMJ,UAAUC,MAAMO,GAAG,EAAEP,MAAMQ,GAAG,EAAEN;AACxC"}
|
package/dist/cjs/fs/lstatReal.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return lstatReal;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _gracefulfs = /*#__PURE__*/ _interop_require_default(require("graceful-fs"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function lstatReal(path, callback) {
|
|
18
|
+
_gracefulfs.default.realpath(path, function realpathCallback(err, realpath) {
|
|
19
|
+
err ? callback(err) : _gracefulfs.default.lstat(realpath, callback);
|
|
6
20
|
});
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
10
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
11
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
12
|
-
module.exports = exports.default;
|
|
13
|
-
}
|
|
21
|
+
}
|
|
22
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["lstatReal.
|
|
1
|
+
{"version":3,"sources":["lstatReal.mjs"],"sourcesContent":["import fs from 'graceful-fs';\n\nexport default function lstatReal(path, callback) {\n fs.realpath(path, function realpathCallback(err, realpath) {\n err ? callback(err) : fs.lstat(realpath, callback);\n });\n}\n"],"names":["lstatReal","path","callback","fs","realpath","realpathCallback","err","lstat"],"mappings":";;;;+BAEA;;;eAAwBA;;;iEAFT;;;;;;AAEA,SAASA,UAAUC,IAAI,EAAEC,QAAQ;IAC9CC,mBAAE,CAACC,QAAQ,CAACH,MAAM,SAASI,iBAAiBC,GAAG,EAAEF,QAAQ;QACvDE,MAAMJ,SAASI,OAAOH,mBAAE,CAACI,KAAK,CAACH,UAAUF;IAC3C;AACF"}
|
package/dist/cjs/fs/utimes.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
// adapted from https://github.com/mafintosh/tar-fs
|
|
2
2
|
"use strict";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return utimes;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _gracefulfs = /*#__PURE__*/ _interop_require_default(require("graceful-fs"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function utimes(fullPath, entry, options, callback) {
|
|
5
19
|
var now = options.now || new Date();
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
10
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
11
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
12
|
-
module.exports = exports.default;
|
|
13
|
-
}
|
|
20
|
+
_gracefulfs.default.utimes(fullPath, now, new Date(entry.mtime), callback);
|
|
21
|
+
}
|
|
22
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["utimes.
|
|
1
|
+
{"version":3,"sources":["utimes.mjs"],"sourcesContent":["// adapted from https://github.com/mafintosh/tar-fs\n\nimport fs from 'graceful-fs';\n\nexport default function utimes(fullPath, entry, options, callback) {\n const now = options.now || new Date();\n fs.utimes(fullPath, now, new Date(entry.mtime), callback);\n}\n"],"names":["utimes","fullPath","entry","options","callback","now","Date","fs","mtime"],"mappings":"AAAA,mDAAmD;;;;;+BAInD;;;eAAwBA;;;iEAFT;;;;;;AAEA,SAASA,OAAOC,QAAQ,EAAEC,KAAK,EAAEC,OAAO,EAAEC,QAAQ;IAC/D,IAAMC,MAAMF,QAAQE,GAAG,IAAI,IAAIC;IAC/BC,mBAAE,CAACP,MAAM,CAACC,UAAUI,KAAK,IAAIC,KAAKJ,MAAMM,KAAK,GAAGJ;AAClD"}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return waitForAccess;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _fsaccesscompat = /*#__PURE__*/ _interop_require_default(require("fs-access-compat"));
|
|
12
|
+
function _interop_require_default(obj) {
|
|
13
|
+
return obj && obj.__esModule ? obj : {
|
|
14
|
+
default: obj
|
|
15
|
+
};
|
|
16
|
+
}
|
|
3
17
|
function waitForAccess(fullPath, callback) {
|
|
4
|
-
|
|
18
|
+
(0, _fsaccesscompat.default)(fullPath, function(err) {
|
|
5
19
|
if (err) return waitForAccess(fullPath, callback);
|
|
6
20
|
callback();
|
|
7
21
|
});
|
|
8
22
|
}
|
|
9
|
-
module.exports =
|
|
10
|
-
|
|
11
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
12
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
13
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
14
|
-
module.exports = exports.default;
|
|
15
|
-
}
|
|
23
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["waitForAccess.
|
|
1
|
+
{"version":3,"sources":["waitForAccess.mjs"],"sourcesContent":["import access from 'fs-access-compat';\n\nexport default function waitForAccess(fullPath, callback) {\n access(fullPath, (err) => {\n if (err) return waitForAccess(fullPath, callback);\n callback();\n });\n}\n"],"names":["waitForAccess","fullPath","callback","access","err"],"mappings":";;;;+BAEA;;;eAAwBA;;;qEAFL;;;;;;AAEJ,SAASA,cAAcC,QAAQ,EAAEC,QAAQ;IACtDC,IAAAA,uBAAM,EAACF,UAAU,SAACG;QAChB,IAAIA,KAAK,OAAOJ,cAAcC,UAAUC;QACxCA;IACF;AACF"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,30 +2,39 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
DirectoryEntry: function() {
|
|
13
|
+
return _DirectoryEntry.default;
|
|
14
|
+
},
|
|
15
|
+
FileEntry: function() {
|
|
16
|
+
return _FileEntry.default;
|
|
17
|
+
},
|
|
18
|
+
LinkEntry: function() {
|
|
19
|
+
return _LinkEntry.default;
|
|
20
|
+
},
|
|
21
|
+
SymbolicLinkEntry: function() {
|
|
22
|
+
return _SymbolicLinkEntry.default;
|
|
23
|
+
},
|
|
24
|
+
default: function() {
|
|
8
25
|
return _default;
|
|
9
26
|
}
|
|
10
27
|
});
|
|
28
|
+
require("./polyfills.js");
|
|
11
29
|
var _stackbaseiterator = /*#__PURE__*/ _interop_require_default(require("stack-base-iterator"));
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
30
|
+
var _DirectoryEntry = /*#__PURE__*/ _interop_require_default(require("./DirectoryEntry.js"));
|
|
31
|
+
var _FileEntry = /*#__PURE__*/ _interop_require_default(require("./FileEntry.js"));
|
|
32
|
+
var _LinkEntry = /*#__PURE__*/ _interop_require_default(require("./LinkEntry.js"));
|
|
33
|
+
var _SymbolicLinkEntry = /*#__PURE__*/ _interop_require_default(require("./SymbolicLinkEntry.js"));
|
|
16
34
|
function _interop_require_default(obj) {
|
|
17
35
|
return obj && obj.__esModule ? obj : {
|
|
18
36
|
default: obj
|
|
19
37
|
};
|
|
20
38
|
}
|
|
21
|
-
_stackbaseiterator.default.DirectoryEntry = _DirectoryEntrycjs.default;
|
|
22
|
-
_stackbaseiterator.default.FileEntry = _FileEntrycjs.default;
|
|
23
|
-
_stackbaseiterator.default.LinkEntry = _LinkEntrycjs.default;
|
|
24
|
-
_stackbaseiterator.default.SymbolicLinkEntry = _SymbolicLinkEntrycjs.default;
|
|
25
39
|
var _default = _stackbaseiterator.default;
|
|
26
|
-
|
|
27
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
28
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
29
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
30
|
-
module.exports = exports.default;
|
|
31
|
-
}
|
|
40
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.mjs"],"sourcesContent":["import StackBaseIterator from 'stack-base-iterator';\
|
|
1
|
+
{"version":3,"sources":["index.mjs"],"sourcesContent":["import './polyfills.cjs';\nimport StackBaseIterator from 'stack-base-iterator';\n\nexport default StackBaseIterator;\nexport { default as DirectoryEntry } from './DirectoryEntry.mjs';\nexport { default as FileEntry } from './FileEntry.mjs';\nexport { default as LinkEntry } from './LinkEntry.mjs';\nexport { default as SymbolicLinkEntry } from './SymbolicLinkEntry.mjs';\n"],"names":["DirectoryEntry","FileEntry","LinkEntry","SymbolicLinkEntry","StackBaseIterator"],"mappings":";;;;;;;;;;;IAIoBA,cAAc;eAAdA,uBAAc;;IACdC,SAAS;eAATA,kBAAS;;IACTC,SAAS;eAATA,kBAAS;;IACTC,iBAAiB;eAAjBA,0BAAiB;;IAJrC,OAAiC;eAAjC;;;QAHO;wEACuB;qEAGY;gEACL;gEACA;wEACQ;;;;;;IAJ7C,WAAeC,0BAAiB"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require("core-js/actual/object/assign");
|
|
3
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["polyfills.cjs"],"sourcesContent":["require('core-js/actual/object/assign');\n"],"names":["require"],"mappings":";AAAAA,QAAQ"}
|
package/dist/cjs/stripPath.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return stripPath;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var _path = /*#__PURE__*/ _interop_require_default(require("path"));
|
|
12
|
+
var _lodashcompact = /*#__PURE__*/ _interop_require_default(require("lodash.compact"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function stripPath(relativePath, options) {
|
|
5
19
|
var strip = options.strip || 0;
|
|
6
20
|
if (!strip) return relativePath;
|
|
7
|
-
var parts =
|
|
21
|
+
var parts = (0, _lodashcompact.default)(relativePath.split(_path.default.sep));
|
|
8
22
|
if (parts.length < strip) throw new Error("You cannot strip more levels than there are directories. Strip: ".concat(strip, ". Path: ").concat(relativePath));
|
|
9
|
-
return parts.slice(strip).join(
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
13
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
14
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
15
|
-
module.exports = exports.default;
|
|
16
|
-
}
|
|
23
|
+
return parts.slice(strip).join(_path.default.sep);
|
|
24
|
+
}
|
|
25
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["stripPath.
|
|
1
|
+
{"version":3,"sources":["stripPath.mjs"],"sourcesContent":["import path from 'path';\nimport compact from 'lodash.compact';\n\nexport default function stripPath(relativePath, options) {\n const strip = options.strip || 0;\n if (!strip) return relativePath;\n const parts = compact(relativePath.split(path.sep));\n if (parts.length < strip) throw new Error(`You cannot strip more levels than there are directories. Strip: ${strip}. Path: ${relativePath}`);\n return parts.slice(strip).join(path.sep);\n}\n"],"names":["stripPath","relativePath","options","strip","parts","compact","split","path","sep","length","Error","slice","join"],"mappings":";;;;+BAGA;;;eAAwBA;;;2DAHP;oEACG;;;;;;AAEL,SAASA,UAAUC,YAAY,EAAEC,OAAO;IACrD,IAAMC,QAAQD,QAAQC,KAAK,IAAI;IAC/B,IAAI,CAACA,OAAO,OAAOF;IACnB,IAAMG,QAAQC,IAAAA,sBAAO,EAACJ,aAAaK,KAAK,CAACC,aAAI,CAACC,GAAG;IACjD,IAAIJ,MAAMK,MAAM,GAAGN,OAAO,MAAM,IAAIO,MAAM,AAAC,mEAAkFT,OAAhBE,OAAM,YAAuB,OAAbF;IAC7H,OAAOG,MAAMO,KAAK,CAACR,OAAOS,IAAI,CAACL,aAAI,CAACC,GAAG;AACzC"}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return validateAttributes;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
function validateAttributes(attributes, keys) {
|
|
3
12
|
var key;
|
|
4
13
|
for(var index = 0; index < keys.length; index++){
|
|
5
14
|
key = keys[index];
|
|
6
15
|
if (attributes[key] === undefined) throw new Error("Missing attribute ".concat(key, ".Attributes ").concat(JSON.stringify(attributes)));
|
|
7
16
|
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
|
|
11
|
-
Object.defineProperty(exports.default, '__esModule', { value: true });
|
|
12
|
-
for (var key in exports) exports.default[key] = exports[key];
|
|
13
|
-
module.exports = exports.default;
|
|
14
|
-
}
|
|
17
|
+
}
|
|
18
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) exports.default[key] = exports[key]; module.exports = exports.default; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["validateAttributes.
|
|
1
|
+
{"version":3,"sources":["validateAttributes.mjs"],"sourcesContent":["export default function validateAttributes(attributes, keys) {\n let key;\n for (let index = 0; index < keys.length; index++) {\n key = keys[index];\n if (attributes[key] === undefined) throw new Error(`Missing attribute ${key}.Attributes ${JSON.stringify(attributes)}`);\n }\n}\n"],"names":["validateAttributes","attributes","keys","key","index","length","undefined","Error","JSON","stringify"],"mappings":";;;;+BAAA;;;eAAwBA;;;AAAT,SAASA,mBAAmBC,UAAU,EAAEC,IAAI;IACzD,IAAIC;IACJ,IAAK,IAAIC,QAAQ,GAAGA,QAAQF,KAAKG,MAAM,EAAED,QAAS;QAChDD,MAAMD,IAAI,CAACE,MAAM;QACjB,IAAIH,UAAU,CAACE,IAAI,KAAKG,WAAW,MAAM,IAAIC,MAAM,AAAC,qBAAsCC,OAAlBL,KAAI,gBAAyC,OAA3BK,KAAKC,SAAS,CAACR;IAC3G;AACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import mkpath from 'mkpath';
|
|
3
|
+
import Queue from 'queue-cb';
|
|
4
|
+
import chmod from './fs/chmod.mjs';
|
|
5
|
+
import chown from './fs/chown.mjs';
|
|
6
|
+
import utimes from './fs/utimes.mjs';
|
|
7
|
+
import stripPath from './stripPath.mjs';
|
|
8
|
+
import validateAttributes from './validateAttributes.mjs';
|
|
9
|
+
const MANDATORY_ATTRIBUTES = [
|
|
10
|
+
'mode',
|
|
11
|
+
'mtime',
|
|
12
|
+
'path'
|
|
13
|
+
];
|
|
14
|
+
export default function DirectoryEntry(attributes) {
|
|
15
|
+
validateAttributes(attributes, MANDATORY_ATTRIBUTES);
|
|
16
|
+
Object.assign(this, attributes);
|
|
17
|
+
if (this.type === undefined) this.type = 'directory';
|
|
18
|
+
if (this.basename === undefined) this.basename = path.basename(this.path);
|
|
19
|
+
}
|
|
20
|
+
DirectoryEntry.prototype.create = function create(dest, options, callback) {
|
|
21
|
+
if (typeof options === 'function') {
|
|
22
|
+
callback = options;
|
|
23
|
+
options = null;
|
|
24
|
+
}
|
|
25
|
+
const self = this;
|
|
26
|
+
if (typeof callback === 'function') {
|
|
27
|
+
options = options || {};
|
|
28
|
+
try {
|
|
29
|
+
const normalizedPath = path.normalize(self.path);
|
|
30
|
+
const fullPath = path.join(dest, stripPath(normalizedPath, options));
|
|
31
|
+
// do not check for the existence of the directory but allow out-of-order calling
|
|
32
|
+
const queue = new Queue(1);
|
|
33
|
+
queue.defer(mkpath.bind(null, fullPath));
|
|
34
|
+
queue.defer(chmod.bind(null, fullPath, self, options));
|
|
35
|
+
queue.defer(chown.bind(null, fullPath, self, options));
|
|
36
|
+
queue.defer(utimes.bind(null, fullPath, self, options));
|
|
37
|
+
return queue.await(callback);
|
|
38
|
+
} catch (err) {
|
|
39
|
+
return callback(err);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return new Promise(function createPromise(resolve, reject) {
|
|
43
|
+
self.create(dest, options, function createCallback(err, done) {
|
|
44
|
+
err ? reject(err) : resolve(done);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
DirectoryEntry.prototype.destroy = function destroy() {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["DirectoryEntry.mjs"],"sourcesContent":["import path from 'path';\nimport mkpath from 'mkpath';\nimport Queue from 'queue-cb';\n\nimport chmod from './fs/chmod.mjs';\nimport chown from './fs/chown.mjs';\nimport utimes from './fs/utimes.mjs';\nimport stripPath from './stripPath.mjs';\nimport validateAttributes from './validateAttributes.mjs';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nexport default function DirectoryEntry(attributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n Object.assign(this, attributes);\n if (this.type === undefined) this.type = 'directory';\n if (this.basename === undefined) this.basename = path.basename(this.path);\n}\n\nDirectoryEntry.prototype.create = function create(dest, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n\n const self = this;\n if (typeof callback === 'function') {\n options = options || {};\n try {\n const normalizedPath = path.normalize(self.path);\n const fullPath = path.join(dest, stripPath(normalizedPath, options));\n\n // do not check for the existence of the directory but allow out-of-order calling\n const queue = new Queue(1);\n queue.defer(mkpath.bind(null, fullPath));\n queue.defer(chmod.bind(null, fullPath, self, options));\n queue.defer(chown.bind(null, fullPath, self, options));\n queue.defer(utimes.bind(null, fullPath, self, options));\n return queue.await(callback);\n } catch (err) {\n return callback(err);\n }\n }\n\n return new Promise(function createPromise(resolve, reject) {\n self.create(dest, options, function createCallback(err, done) {\n err ? reject(err) : resolve(done);\n });\n });\n};\n\nDirectoryEntry.prototype.destroy = function destroy() {};\n"],"names":["path","mkpath","Queue","chmod","chown","utimes","stripPath","validateAttributes","MANDATORY_ATTRIBUTES","DirectoryEntry","attributes","Object","assign","type","undefined","basename","prototype","create","dest","options","callback","self","normalizedPath","normalize","fullPath","join","queue","defer","bind","await","err","Promise","createPromise","resolve","reject","createCallback","done","destroy"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,YAAY,SAAS;AAC5B,OAAOC,WAAW,WAAW;AAE7B,OAAOC,WAAW,iBAAiB;AACnC,OAAOC,WAAW,iBAAiB;AACnC,OAAOC,YAAY,kBAAkB;AACrC,OAAOC,eAAe,kBAAkB;AACxC,OAAOC,wBAAwB,2BAA2B;AAE1D,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;CAAO;AAEtD,eAAe,SAASC,eAAeC,UAAU;IAC/CH,mBAAmBG,YAAYF;IAC/BG,OAAOC,MAAM,CAAC,IAAI,EAAEF;IACpB,IAAI,IAAI,CAACG,IAAI,KAAKC,WAAW,IAAI,CAACD,IAAI,GAAG;IACzC,IAAI,IAAI,CAACE,QAAQ,KAAKD,WAAW,IAAI,CAACC,QAAQ,GAAGf,KAAKe,QAAQ,CAAC,IAAI,CAACf,IAAI;AAC1E;AAEAS,eAAeO,SAAS,CAACC,MAAM,GAAG,SAASA,OAAOC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACvE,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IAEA,MAAME,OAAO,IAAI;IACjB,IAAI,OAAOD,aAAa,YAAY;QAClCD,UAAUA,WAAW,CAAC;QACtB,IAAI;YACF,MAAMG,iBAAiBtB,KAAKuB,SAAS,CAACF,KAAKrB,IAAI;YAC/C,MAAMwB,WAAWxB,KAAKyB,IAAI,CAACP,MAAMZ,UAAUgB,gBAAgBH;YAE3D,iFAAiF;YACjF,MAAMO,QAAQ,IAAIxB,MAAM;YACxBwB,MAAMC,KAAK,CAAC1B,OAAO2B,IAAI,CAAC,MAAMJ;YAC9BE,MAAMC,KAAK,CAACxB,MAAMyB,IAAI,CAAC,MAAMJ,UAAUH,MAAMF;YAC7CO,MAAMC,KAAK,CAACvB,MAAMwB,IAAI,CAAC,MAAMJ,UAAUH,MAAMF;YAC7CO,MAAMC,KAAK,CAACtB,OAAOuB,IAAI,CAAC,MAAMJ,UAAUH,MAAMF;YAC9C,OAAOO,MAAMG,KAAK,CAACT;QACrB,EAAE,OAAOU,KAAK;YACZ,OAAOV,SAASU;QAClB;IACF;IAEA,OAAO,IAAIC,QAAQ,SAASC,cAAcC,OAAO,EAAEC,MAAM;QACvDb,KAAKJ,MAAM,CAACC,MAAMC,SAAS,SAASgB,eAAeL,GAAG,EAAEM,IAAI;YAC1DN,MAAMI,OAAOJ,OAAOG,QAAQG;QAC9B;IACF;AACF;AAEA3B,eAAeO,SAAS,CAACqB,OAAO,GAAG,SAASA,WAAW"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import mkpath from 'mkpath';
|
|
3
|
+
import Queue from 'queue-cb';
|
|
4
|
+
import rimraf from 'rimraf';
|
|
5
|
+
import chmod from './fs/chmod.mjs';
|
|
6
|
+
import chown from './fs/chown.mjs';
|
|
7
|
+
import utimes from './fs/utimes.mjs';
|
|
8
|
+
import stripPath from './stripPath.mjs';
|
|
9
|
+
import validateAttributes from './validateAttributes.mjs';
|
|
10
|
+
const MANDATORY_ATTRIBUTES = [
|
|
11
|
+
'mode',
|
|
12
|
+
'mtime',
|
|
13
|
+
'path'
|
|
14
|
+
];
|
|
15
|
+
export default function FileEntry(attributes) {
|
|
16
|
+
validateAttributes(attributes, MANDATORY_ATTRIBUTES);
|
|
17
|
+
Object.assign(this, attributes);
|
|
18
|
+
if (this.basename === undefined) this.basename = path.basename(this.path);
|
|
19
|
+
if (this.type === undefined) this.type = 'file';
|
|
20
|
+
if (this._writeFile === undefined) throw new Error('File self missing _writeFile. Please implement this method in your subclass');
|
|
21
|
+
}
|
|
22
|
+
FileEntry.prototype.create = function create(dest, options, callback) {
|
|
23
|
+
if (typeof options === 'function') {
|
|
24
|
+
callback = options;
|
|
25
|
+
options = null;
|
|
26
|
+
}
|
|
27
|
+
const self = this;
|
|
28
|
+
if (typeof callback === 'function') {
|
|
29
|
+
options = options || {};
|
|
30
|
+
try {
|
|
31
|
+
const normalizedPath = path.normalize(self.path);
|
|
32
|
+
const fullPath = path.join(dest, stripPath(normalizedPath, options));
|
|
33
|
+
const queue = new Queue(1);
|
|
34
|
+
if (options.force) {
|
|
35
|
+
queue.defer((callback)=>{
|
|
36
|
+
rimraf(fullPath, (err)=>{
|
|
37
|
+
err && err.code !== 'ENOENT' ? callback(err) : callback();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
queue.defer(mkpath.bind(null, path.dirname(fullPath)));
|
|
42
|
+
queue.defer(this._writeFile.bind(this, fullPath, options));
|
|
43
|
+
queue.defer(chmod.bind(null, fullPath, self, options));
|
|
44
|
+
queue.defer(chown.bind(null, fullPath, self, options));
|
|
45
|
+
queue.defer(utimes.bind(null, fullPath, self, options));
|
|
46
|
+
return queue.await(callback);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
return callback(err);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return new Promise(function createPromise(resolve, reject) {
|
|
52
|
+
self.create(dest, options, function createCallback(err, done) {
|
|
53
|
+
err ? reject(err) : resolve(done);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
FileEntry.prototype.destroy = function destroy() {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["FileEntry.mjs"],"sourcesContent":["import path from 'path';\nimport mkpath from 'mkpath';\nimport Queue from 'queue-cb';\n\nimport rimraf from 'rimraf';\nimport chmod from './fs/chmod.mjs';\nimport chown from './fs/chown.mjs';\nimport utimes from './fs/utimes.mjs';\nimport stripPath from './stripPath.mjs';\nimport validateAttributes from './validateAttributes.mjs';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nexport default function FileEntry(attributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n Object.assign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'file';\n if (this._writeFile === undefined) throw new Error('File self missing _writeFile. Please implement this method in your subclass');\n}\n\nFileEntry.prototype.create = function create(dest, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n\n const self = this;\n if (typeof callback === 'function') {\n options = options || {};\n try {\n const normalizedPath = path.normalize(self.path);\n const fullPath = path.join(dest, stripPath(normalizedPath, options));\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rimraf(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n }\n queue.defer(mkpath.bind(null, path.dirname(fullPath)));\n queue.defer(this._writeFile.bind(this, fullPath, options));\n queue.defer(chmod.bind(null, fullPath, self, options));\n queue.defer(chown.bind(null, fullPath, self, options));\n queue.defer(utimes.bind(null, fullPath, self, options));\n return queue.await(callback);\n } catch (err) {\n return callback(err);\n }\n }\n\n return new Promise(function createPromise(resolve, reject) {\n self.create(dest, options, function createCallback(err, done) {\n err ? reject(err) : resolve(done);\n });\n });\n};\n\nFileEntry.prototype.destroy = function destroy() {};\n"],"names":["path","mkpath","Queue","rimraf","chmod","chown","utimes","stripPath","validateAttributes","MANDATORY_ATTRIBUTES","FileEntry","attributes","Object","assign","basename","undefined","type","_writeFile","Error","prototype","create","dest","options","callback","self","normalizedPath","normalize","fullPath","join","queue","force","defer","err","code","bind","dirname","await","Promise","createPromise","resolve","reject","createCallback","done","destroy"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,YAAY,SAAS;AAC5B,OAAOC,WAAW,WAAW;AAE7B,OAAOC,YAAY,SAAS;AAC5B,OAAOC,WAAW,iBAAiB;AACnC,OAAOC,WAAW,iBAAiB;AACnC,OAAOC,YAAY,kBAAkB;AACrC,OAAOC,eAAe,kBAAkB;AACxC,OAAOC,wBAAwB,2BAA2B;AAE1D,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;CAAO;AAEtD,eAAe,SAASC,UAAUC,UAAU;IAC1CH,mBAAmBG,YAAYF;IAC/BG,OAAOC,MAAM,CAAC,IAAI,EAAEF;IACpB,IAAI,IAAI,CAACG,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGd,KAAKc,QAAQ,CAAC,IAAI,CAACd,IAAI;IACxE,IAAI,IAAI,CAACgB,IAAI,KAAKD,WAAW,IAAI,CAACC,IAAI,GAAG;IACzC,IAAI,IAAI,CAACC,UAAU,KAAKF,WAAW,MAAM,IAAIG,MAAM;AACrD;AAEAR,UAAUS,SAAS,CAACC,MAAM,GAAG,SAASA,OAAOC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAClE,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IAEA,MAAME,OAAO,IAAI;IACjB,IAAI,OAAOD,aAAa,YAAY;QAClCD,UAAUA,WAAW,CAAC;QACtB,IAAI;YACF,MAAMG,iBAAiBzB,KAAK0B,SAAS,CAACF,KAAKxB,IAAI;YAC/C,MAAM2B,WAAW3B,KAAK4B,IAAI,CAACP,MAAMd,UAAUkB,gBAAgBH;YAE3D,MAAMO,QAAQ,IAAI3B,MAAM;YACxB,IAAIoB,QAAQQ,KAAK,EAAE;gBACjBD,MAAME,KAAK,CAAC,CAACR;oBACXpB,OAAOwB,UAAU,CAACK;wBAChBA,OAAOA,IAAIC,IAAI,KAAK,WAAWV,SAASS,OAAOT;oBACjD;gBACF;YACF;YACAM,MAAME,KAAK,CAAC9B,OAAOiC,IAAI,CAAC,MAAMlC,KAAKmC,OAAO,CAACR;YAC3CE,MAAME,KAAK,CAAC,IAAI,CAACd,UAAU,CAACiB,IAAI,CAAC,IAAI,EAAEP,UAAUL;YACjDO,MAAME,KAAK,CAAC3B,MAAM8B,IAAI,CAAC,MAAMP,UAAUH,MAAMF;YAC7CO,MAAME,KAAK,CAAC1B,MAAM6B,IAAI,CAAC,MAAMP,UAAUH,MAAMF;YAC7CO,MAAME,KAAK,CAACzB,OAAO4B,IAAI,CAAC,MAAMP,UAAUH,MAAMF;YAC9C,OAAOO,MAAMO,KAAK,CAACb;QACrB,EAAE,OAAOS,KAAK;YACZ,OAAOT,SAASS;QAClB;IACF;IAEA,OAAO,IAAIK,QAAQ,SAASC,cAAcC,OAAO,EAAEC,MAAM;QACvDhB,KAAKJ,MAAM,CAACC,MAAMC,SAAS,SAASmB,eAAeT,GAAG,EAAEU,IAAI;YAC1DV,MAAMQ,OAAOR,OAAOO,QAAQG;QAC9B;IACF;AACF;AAEAhC,UAAUS,SAAS,CAACwB,OAAO,GAAG,SAASA,WAAW"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'graceful-fs';
|
|
3
|
+
import mkpath from 'mkpath';
|
|
4
|
+
import Queue from 'queue-cb';
|
|
5
|
+
import rimraf from 'rimraf';
|
|
6
|
+
import chmod from './fs/chmod.mjs';
|
|
7
|
+
import chown from './fs/chown.mjs';
|
|
8
|
+
import utimes from './fs/utimes.mjs';
|
|
9
|
+
import stripPath from './stripPath.mjs';
|
|
10
|
+
import validateAttributes from './validateAttributes.mjs';
|
|
11
|
+
const MANDATORY_ATTRIBUTES = [
|
|
12
|
+
'mode',
|
|
13
|
+
'mtime',
|
|
14
|
+
'path',
|
|
15
|
+
'linkpath'
|
|
16
|
+
];
|
|
17
|
+
export default function LinkEntry(attributes, _type) {
|
|
18
|
+
validateAttributes(attributes, MANDATORY_ATTRIBUTES);
|
|
19
|
+
Object.assign(this, attributes);
|
|
20
|
+
if (this.basename === undefined) this.basename = path.basename(this.path);
|
|
21
|
+
if (this.type === undefined) this.type = 'link';
|
|
22
|
+
}
|
|
23
|
+
LinkEntry.prototype.create = function create(dest, options, callback) {
|
|
24
|
+
if (typeof options === 'function') {
|
|
25
|
+
callback = options;
|
|
26
|
+
options = null;
|
|
27
|
+
}
|
|
28
|
+
const self = this;
|
|
29
|
+
if (typeof callback === 'function') {
|
|
30
|
+
options = options || {};
|
|
31
|
+
try {
|
|
32
|
+
const normalizedPath = path.normalize(self.path);
|
|
33
|
+
const fullPath = path.join(dest, stripPath(normalizedPath, options));
|
|
34
|
+
const normalizedLinkpath = path.normalize(self.linkpath);
|
|
35
|
+
const linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));
|
|
36
|
+
const queue = new Queue(1);
|
|
37
|
+
if (options.force) {
|
|
38
|
+
queue.defer((callback)=>{
|
|
39
|
+
rimraf(fullPath, (err)=>{
|
|
40
|
+
err && err.code !== 'ENOENT' ? callback(err) : callback();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
queue.defer(mkpath.bind(null, path.dirname(fullPath)));
|
|
45
|
+
queue.defer(fs.link.bind(fs, linkFullPath, fullPath));
|
|
46
|
+
queue.defer(chmod.bind(null, fullPath, self, options));
|
|
47
|
+
queue.defer(chown.bind(null, fullPath, self, options));
|
|
48
|
+
queue.defer(utimes.bind(null, fullPath, self, options));
|
|
49
|
+
return queue.await(callback);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
return callback(err);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return new Promise(function createPromise(resolve, reject) {
|
|
55
|
+
self.create(dest, options, function createCallback(err, done) {
|
|
56
|
+
err ? reject(err) : resolve(done);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
LinkEntry.prototype.destroy = function destroy() {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["LinkEntry.mjs"],"sourcesContent":["import path from 'path';\nimport fs from 'graceful-fs';\nimport mkpath from 'mkpath';\nimport Queue from 'queue-cb';\nimport rimraf from 'rimraf';\n\nimport chmod from './fs/chmod.mjs';\nimport chown from './fs/chown.mjs';\nimport utimes from './fs/utimes.mjs';\nimport stripPath from './stripPath.mjs';\nimport validateAttributes from './validateAttributes.mjs';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nexport default function LinkEntry(attributes, _type) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n Object.assign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'link';\n}\n\nLinkEntry.prototype.create = function create(dest, options, callback) {\n if (typeof options === 'function') {\n callback = options;\n options = null;\n }\n\n const self = this;\n if (typeof callback === 'function') {\n options = options || {};\n try {\n const normalizedPath = path.normalize(self.path);\n const fullPath = path.join(dest, stripPath(normalizedPath, options));\n const normalizedLinkpath = path.normalize(self.linkpath);\n const linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));\n\n const queue = new Queue(1);\n if (options.force) {\n queue.defer((callback) => {\n rimraf(fullPath, (err) => {\n err && err.code !== 'ENOENT' ? callback(err) : callback();\n });\n });\n }\n queue.defer(mkpath.bind(null, path.dirname(fullPath)));\n queue.defer(fs.link.bind(fs, linkFullPath, fullPath));\n queue.defer(chmod.bind(null, fullPath, self, options));\n queue.defer(chown.bind(null, fullPath, self, options));\n queue.defer(utimes.bind(null, fullPath, self, options));\n return queue.await(callback);\n } catch (err) {\n return callback(err);\n }\n }\n\n return new Promise(function createPromise(resolve, reject) {\n self.create(dest, options, function createCallback(err, done) {\n err ? reject(err) : resolve(done);\n });\n });\n};\n\nLinkEntry.prototype.destroy = function destroy() {};\n"],"names":["path","fs","mkpath","Queue","rimraf","chmod","chown","utimes","stripPath","validateAttributes","MANDATORY_ATTRIBUTES","LinkEntry","attributes","_type","Object","assign","basename","undefined","type","prototype","create","dest","options","callback","self","normalizedPath","normalize","fullPath","join","normalizedLinkpath","linkpath","linkFullPath","queue","force","defer","err","code","bind","dirname","link","await","Promise","createPromise","resolve","reject","createCallback","done","destroy"],"mappings":"AAAA,OAAOA,UAAU,OAAO;AACxB,OAAOC,QAAQ,cAAc;AAC7B,OAAOC,YAAY,SAAS;AAC5B,OAAOC,WAAW,WAAW;AAC7B,OAAOC,YAAY,SAAS;AAE5B,OAAOC,WAAW,iBAAiB;AACnC,OAAOC,WAAW,iBAAiB;AACnC,OAAOC,YAAY,kBAAkB;AACrC,OAAOC,eAAe,kBAAkB;AACxC,OAAOC,wBAAwB,2BAA2B;AAE1D,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;IAAQ;CAAW;AAElE,eAAe,SAASC,UAAUC,UAAU,EAAEC,KAAK;IACjDJ,mBAAmBG,YAAYF;IAC/BI,OAAOC,MAAM,CAAC,IAAI,EAAEH;IACpB,IAAI,IAAI,CAACI,QAAQ,KAAKC,WAAW,IAAI,CAACD,QAAQ,GAAGhB,KAAKgB,QAAQ,CAAC,IAAI,CAAChB,IAAI;IACxE,IAAI,IAAI,CAACkB,IAAI,KAAKD,WAAW,IAAI,CAACC,IAAI,GAAG;AAC3C;AAEAP,UAAUQ,SAAS,CAACC,MAAM,GAAG,SAASA,OAAOC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IAClE,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IAEA,MAAME,OAAO,IAAI;IACjB,IAAI,OAAOD,aAAa,YAAY;QAClCD,UAAUA,WAAW,CAAC;QACtB,IAAI;YACF,MAAMG,iBAAiBzB,KAAK0B,SAAS,CAACF,KAAKxB,IAAI;YAC/C,MAAM2B,WAAW3B,KAAK4B,IAAI,CAACP,MAAMb,UAAUiB,gBAAgBH;YAC3D,MAAMO,qBAAqB7B,KAAK0B,SAAS,CAACF,KAAKM,QAAQ;YACvD,MAAMC,eAAe/B,KAAK4B,IAAI,CAACP,MAAMb,UAAUqB,oBAAoBP;YAEnE,MAAMU,QAAQ,IAAI7B,MAAM;YACxB,IAAImB,QAAQW,KAAK,EAAE;gBACjBD,MAAME,KAAK,CAAC,CAACX;oBACXnB,OAAOuB,UAAU,CAACQ;wBAChBA,OAAOA,IAAIC,IAAI,KAAK,WAAWb,SAASY,OAAOZ;oBACjD;gBACF;YACF;YACAS,MAAME,KAAK,CAAChC,OAAOmC,IAAI,CAAC,MAAMrC,KAAKsC,OAAO,CAACX;YAC3CK,MAAME,KAAK,CAACjC,GAAGsC,IAAI,CAACF,IAAI,CAACpC,IAAI8B,cAAcJ;YAC3CK,MAAME,KAAK,CAAC7B,MAAMgC,IAAI,CAAC,MAAMV,UAAUH,MAAMF;YAC7CU,MAAME,KAAK,CAAC5B,MAAM+B,IAAI,CAAC,MAAMV,UAAUH,MAAMF;YAC7CU,MAAME,KAAK,CAAC3B,OAAO8B,IAAI,CAAC,MAAMV,UAAUH,MAAMF;YAC9C,OAAOU,MAAMQ,KAAK,CAACjB;QACrB,EAAE,OAAOY,KAAK;YACZ,OAAOZ,SAASY;QAClB;IACF;IAEA,OAAO,IAAIM,QAAQ,SAASC,cAAcC,OAAO,EAAEC,MAAM;QACvDpB,KAAKJ,MAAM,CAACC,MAAMC,SAAS,SAASuB,eAAeV,GAAG,EAAEW,IAAI;YAC1DX,MAAMS,OAAOT,OAAOQ,QAAQG;QAC9B;IACF;AACF;AAEAnC,UAAUQ,SAAS,CAAC4B,OAAO,GAAG,SAASA,WAAW"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'graceful-fs';
|
|
3
|
+
import isAbsolute from 'is-absolute';
|
|
4
|
+
import mkpath from 'mkpath';
|
|
5
|
+
import Queue from 'queue-cb';
|
|
6
|
+
import rimraf from 'rimraf';
|
|
7
|
+
import chmod from './fs/chmod.mjs';
|
|
8
|
+
import chown from './fs/chown.mjs';
|
|
9
|
+
import lstatReal from './fs/lstatReal.mjs';
|
|
10
|
+
import utimes from './fs/utimes.mjs';
|
|
11
|
+
import stripPath from './stripPath.mjs';
|
|
12
|
+
import validateAttributes from './validateAttributes.mjs';
|
|
13
|
+
function symlinkWin32(linkFullPath, linkpath, fullPath, callback) {
|
|
14
|
+
lstatReal(linkFullPath, (err, targetStat)=>{
|
|
15
|
+
if (err || !targetStat) return callback(err || new Error(`Symlink path does not exist${linkFullPath}`));
|
|
16
|
+
const type = targetStat.isDirectory() ? 'dir' : 'file';
|
|
17
|
+
fs.symlink(linkpath, fullPath, type, callback);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const isWindows = process.platform === 'win32';
|
|
21
|
+
const MANDATORY_ATTRIBUTES = [
|
|
22
|
+
'mode',
|
|
23
|
+
'mtime',
|
|
24
|
+
'path',
|
|
25
|
+
'linkpath'
|
|
26
|
+
];
|
|
27
|
+
export default function SymbolicLinkEntry(attributes) {
|
|
28
|
+
validateAttributes(attributes, MANDATORY_ATTRIBUTES);
|
|
29
|
+
Object.assign(this, attributes);
|
|
30
|
+
if (this.basename === undefined) this.basename = path.basename(this.path);
|
|
31
|
+
if (this.type === undefined) this.type = 'symlink';
|
|
32
|
+
}
|
|
33
|
+
SymbolicLinkEntry.prototype.create = function create(dest, options, callback) {
|
|
34
|
+
if (typeof options === 'function') {
|
|
35
|
+
callback = options;
|
|
36
|
+
options = null;
|
|
37
|
+
}
|
|
38
|
+
const self = this;
|
|
39
|
+
if (typeof callback === 'function') {
|
|
40
|
+
options = options || {};
|
|
41
|
+
try {
|
|
42
|
+
const normalizedPath = path.normalize(self.path);
|
|
43
|
+
const fullPath = path.join(dest, stripPath(normalizedPath, options));
|
|
44
|
+
let normalizedLinkpath = path.normalize(self.linkpath);
|
|
45
|
+
let linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));
|
|
46
|
+
if (!isAbsolute(normalizedLinkpath)) {
|
|
47
|
+
const linkRelativePath = path.join(path.dirname(normalizedPath), self.linkpath);
|
|
48
|
+
linkFullPath = path.join(dest, stripPath(linkRelativePath, options));
|
|
49
|
+
normalizedLinkpath = path.relative(path.dirname(fullPath), linkFullPath);
|
|
50
|
+
}
|
|
51
|
+
const queue = new Queue(1);
|
|
52
|
+
if (options.force) {
|
|
53
|
+
queue.defer((callback)=>{
|
|
54
|
+
rimraf(fullPath, (err)=>{
|
|
55
|
+
err && err.code !== 'ENOENT' ? callback(err) : callback();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
queue.defer(mkpath.bind(null, path.dirname(fullPath)));
|
|
60
|
+
if (isWindows) queue.defer(symlinkWin32.bind(null, linkFullPath, normalizedLinkpath, fullPath));
|
|
61
|
+
else queue.defer(fs.symlink.bind(fs, normalizedLinkpath, fullPath));
|
|
62
|
+
queue.defer(chmod.bind(null, fullPath, self, options));
|
|
63
|
+
queue.defer(chown.bind(null, fullPath, self, options));
|
|
64
|
+
queue.defer(utimes.bind(null, fullPath, self, options));
|
|
65
|
+
return queue.await(callback);
|
|
66
|
+
} catch (err) {
|
|
67
|
+
return callback(err);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return new Promise(function createPromise(resolve, reject) {
|
|
71
|
+
self.create(dest, options, function createCallback(err, done) {
|
|
72
|
+
err ? reject(err) : resolve(done);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
SymbolicLinkEntry.prototype.destroy = function destroy() {};
|