extract-base-iterator 0.2.5 → 0.3.0

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.
Files changed (50) hide show
  1. package/dist/cjs/DirectoryEntry.js +57 -0
  2. package/dist/cjs/DirectoryEntry.js.map +1 -0
  3. package/dist/cjs/FileEntry.js +66 -0
  4. package/dist/cjs/FileEntry.js.map +1 -0
  5. package/dist/cjs/LinkEntry.js +69 -0
  6. package/dist/cjs/LinkEntry.js.map +1 -0
  7. package/dist/cjs/SymbolicLinkEntry.js +85 -0
  8. package/dist/cjs/SymbolicLinkEntry.js.map +1 -0
  9. package/dist/cjs/fs/chmod.js +36 -0
  10. package/dist/cjs/fs/chmod.js.map +1 -0
  11. package/dist/cjs/fs/chown.js +16 -0
  12. package/dist/cjs/fs/chown.js.map +1 -0
  13. package/dist/cjs/fs/lstatReal.js +13 -0
  14. package/dist/cjs/fs/lstatReal.js.map +1 -0
  15. package/dist/cjs/fs/utimes.js +13 -0
  16. package/dist/cjs/fs/utimes.js.map +1 -0
  17. package/dist/cjs/fs/waitForAccess.js +15 -0
  18. package/dist/cjs/fs/waitForAccess.js.map +1 -0
  19. package/dist/cjs/index.js +12 -0
  20. package/dist/cjs/index.js.map +1 -0
  21. package/dist/cjs/package.json +1 -0
  22. package/dist/cjs/stripPath.js +16 -0
  23. package/dist/cjs/stripPath.js.map +1 -0
  24. package/dist/cjs/validateAttributes.js +14 -0
  25. package/dist/cjs/validateAttributes.js.map +1 -0
  26. package/dist/types/DirectoryEntry.d.ts +9 -0
  27. package/dist/types/FileEntry.d.ts +9 -0
  28. package/dist/types/LinkEntry.d.ts +9 -0
  29. package/dist/types/SymbolicLinkEntry.d.ts +9 -0
  30. package/dist/types/fs/chmod.d.ts +2 -0
  31. package/dist/types/fs/chown.d.ts +2 -0
  32. package/dist/types/fs/lstatReal.d.ts +2 -0
  33. package/dist/types/fs/utimes.d.ts +2 -0
  34. package/dist/types/fs/waitForAccess.d.ts +2 -0
  35. package/dist/types/index.d.ts +6 -0
  36. package/dist/types/stripPath.d.ts +2 -0
  37. package/dist/types/validateAttributes.d.ts +2 -0
  38. package/package.json +30 -25
  39. package/index.js +0 -5
  40. package/lib/DirectoryEntry.js +0 -55
  41. package/lib/FileEntry.js +0 -64
  42. package/lib/LinkEntry.js +0 -66
  43. package/lib/SymbolicLinkEntry.js +0 -83
  44. package/lib/fs/chmod.js +0 -34
  45. package/lib/fs/chown.js +0 -12
  46. package/lib/fs/lstatReal.js +0 -7
  47. package/lib/fs/utimes.js +0 -8
  48. package/lib/fs/waitForAccess.js +0 -10
  49. package/lib/stripPath.js +0 -10
  50. package/lib/validateAttributes.js +0 -7
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var path = require("path");
3
+ var mkpath = require("mkpath");
4
+ var Queue = require("queue-cb");
5
+ var assign = require("just-extend");
6
+ var chmod = require("./fs/chmod");
7
+ var chown = require("./fs/chown");
8
+ var utimes = require("./fs/utimes");
9
+ var stripPath = require("./stripPath");
10
+ var validateAttributes = require("./validateAttributes");
11
+ var MANDATORY_ATTRIBUTES = [
12
+ "mode",
13
+ "mtime",
14
+ "path"
15
+ ];
16
+ function DirectoryEntry(attributes) {
17
+ validateAttributes(attributes, MANDATORY_ATTRIBUTES);
18
+ assign(this, attributes);
19
+ if (this.type === undefined) this.type = "directory";
20
+ if (this.basename === undefined) this.basename = path.basename(this.path);
21
+ }
22
+ DirectoryEntry.prototype.create = function create(dest, options, callback) {
23
+ if (typeof options === "function") {
24
+ callback = options;
25
+ options = null;
26
+ }
27
+ var self = this;
28
+ if (typeof callback === "function") {
29
+ options = options || {};
30
+ try {
31
+ var normalizedPath = path.normalize(self.path);
32
+ var fullPath = path.join(dest, stripPath(normalizedPath, options));
33
+ // do not check for the existence of the directory but allow out-of-order calling
34
+ var queue = new Queue(1);
35
+ queue.defer(mkpath.bind(null, fullPath));
36
+ queue.defer(chmod.bind(null, fullPath, self, options));
37
+ queue.defer(chown.bind(null, fullPath, self, options));
38
+ queue.defer(utimes.bind(null, fullPath, self, options));
39
+ return queue.await(callback);
40
+ } catch (err) {
41
+ return callback(err);
42
+ }
43
+ }
44
+ return new Promise(function createPromise(resolve, reject) {
45
+ self.create(dest, options, function createCallback(err, done) {
46
+ err ? reject(err) : resolve(done);
47
+ });
48
+ });
49
+ };
50
+ DirectoryEntry.prototype.destroy = function destroy() {};
51
+ module.exports = DirectoryEntry;
52
+
53
+ if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
54
+ Object.defineProperty(exports.default, '__esModule', { value: true });
55
+ for (var key in exports) exports.default[key] = exports[key];
56
+ module.exports = exports.default;
57
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["DirectoryEntry.js"],"sourcesContent":["const path = require('path');\nconst mkpath = require('mkpath');\nconst Queue = require('queue-cb');\nconst assign = require('just-extend');\n\nconst chmod = require('./fs/chmod');\nconst chown = require('./fs/chown');\nconst utimes = require('./fs/utimes');\nconst stripPath = require('./stripPath');\nconst validateAttributes = require('./validateAttributes');\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nfunction DirectoryEntry(attributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n 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\nmodule.exports = DirectoryEntry;\n"],"names":["path","require","mkpath","Queue","assign","chmod","chown","utimes","stripPath","validateAttributes","MANDATORY_ATTRIBUTES","DirectoryEntry","attributes","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","module","exports"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,SAASD,QAAQ;AACvB,IAAME,QAAQF,QAAQ;AACtB,IAAMG,SAASH,QAAQ;AAEvB,IAAMI,QAAQJ,QAAQ;AACtB,IAAMK,QAAQL,QAAQ;AACtB,IAAMM,SAASN,QAAQ;AACvB,IAAMO,YAAYP,QAAQ;AAC1B,IAAMQ,qBAAqBR,QAAQ;AAEnC,IAAMS,uBAAuB;IAAC;IAAQ;IAAS;CAAO;AAEtD,SAASC,eAAeC,UAAU;IAChCH,mBAAmBG,YAAYF;IAC/BN,OAAO,IAAI,EAAEQ;IACb,IAAI,IAAI,CAACC,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;AAEAW,eAAeK,SAAS,CAACC,MAAM,GAAG,SAASA,OAAOC,IAAI,EAAEC,OAAO,EAAEC,QAAQ;IACvE,IAAI,OAAOD,YAAY,YAAY;QACjCC,WAAWD;QACXA,UAAU;IACZ;IAEA,IAAME,OAAO,IAAI;IACjB,IAAI,OAAOD,aAAa,YAAY;QAClCD,UAAUA,WAAW,CAAC;QACtB,IAAI;YACF,IAAMG,iBAAiBtB,KAAKuB,SAAS,CAACF,KAAKrB,IAAI;YAC/C,IAAMwB,WAAWxB,KAAKyB,IAAI,CAACP,MAAMV,UAAUc,gBAAgBH;YAE3D,iFAAiF;YACjF,IAAMO,QAAQ,IAAIvB,MAAM;YACxBuB,MAAMC,KAAK,CAACzB,OAAO0B,IAAI,CAAC,MAAMJ;YAC9BE,MAAMC,KAAK,CAACtB,MAAMuB,IAAI,CAAC,MAAMJ,UAAUH,MAAMF;YAC7CO,MAAMC,KAAK,CAACrB,MAAMsB,IAAI,CAAC,MAAMJ,UAAUH,MAAMF;YAC7CO,MAAMC,KAAK,CAACpB,OAAOqB,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;AAEAzB,eAAeK,SAAS,CAACqB,OAAO,GAAG,SAASA,WAAW;AAEvDC,OAAOC,OAAO,GAAG5B"}
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var path = require("path");
3
+ var mkpath = require("mkpath");
4
+ var Queue = require("queue-cb");
5
+ var assign = require("just-extend");
6
+ var chmod = require("./fs/chmod");
7
+ var chown = require("./fs/chown");
8
+ var rimraf = require("rimraf");
9
+ var utimes = require("./fs/utimes");
10
+ var stripPath = require("./stripPath");
11
+ var validateAttributes = require("./validateAttributes");
12
+ var MANDATORY_ATTRIBUTES = [
13
+ "mode",
14
+ "mtime",
15
+ "path"
16
+ ];
17
+ function FileEntry(attributes) {
18
+ validateAttributes(attributes, MANDATORY_ATTRIBUTES);
19
+ assign(this, attributes);
20
+ if (this.basename === undefined) this.basename = path.basename(this.path);
21
+ if (this.type === undefined) this.type = "file";
22
+ if (this._writeFile === undefined) throw new Error("File self missing _writeFile. Please implement this method in your subclass");
23
+ }
24
+ FileEntry.prototype.create = function create(dest, options, callback) {
25
+ if (typeof options === "function") {
26
+ callback = options;
27
+ options = null;
28
+ }
29
+ var self = this;
30
+ if (typeof callback === "function") {
31
+ options = options || {};
32
+ try {
33
+ var normalizedPath = path.normalize(self.path);
34
+ var fullPath = path.join(dest, stripPath(normalizedPath, options));
35
+ var queue = new Queue(1);
36
+ if (options.force) {
37
+ queue.defer(function(callback) {
38
+ rimraf(fullPath, function(err) {
39
+ err && err.code !== "ENOENT" ? callback(err) : callback();
40
+ });
41
+ });
42
+ }
43
+ queue.defer(mkpath.bind(null, path.dirname(fullPath)));
44
+ queue.defer(this._writeFile.bind(this, fullPath, options));
45
+ queue.defer(chmod.bind(null, fullPath, self, options));
46
+ queue.defer(chown.bind(null, fullPath, self, options));
47
+ queue.defer(utimes.bind(null, fullPath, self, options));
48
+ return queue.await(callback);
49
+ } catch (err) {
50
+ return callback(err);
51
+ }
52
+ }
53
+ return new Promise(function createPromise(resolve, reject) {
54
+ self.create(dest, options, function createCallback(err, done) {
55
+ err ? reject(err) : resolve(done);
56
+ });
57
+ });
58
+ };
59
+ FileEntry.prototype.destroy = function destroy() {};
60
+ module.exports = FileEntry;
61
+
62
+ if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
63
+ Object.defineProperty(exports.default, '__esModule', { value: true });
64
+ for (var key in exports) exports.default[key] = exports[key];
65
+ module.exports = exports.default;
66
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["FileEntry.js"],"sourcesContent":["const path = require('path');\nconst mkpath = require('mkpath');\nconst Queue = require('queue-cb');\nconst assign = require('just-extend');\n\nconst chmod = require('./fs/chmod');\nconst chown = require('./fs/chown');\nconst rimraf = require('rimraf');\nconst utimes = require('./fs/utimes');\nconst stripPath = require('./stripPath');\nconst validateAttributes = require('./validateAttributes');\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];\n\nfunction FileEntry(attributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n 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\nmodule.exports = FileEntry;\n"],"names":["path","require","mkpath","Queue","assign","chmod","chown","rimraf","utimes","stripPath","validateAttributes","MANDATORY_ATTRIBUTES","FileEntry","attributes","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","module","exports"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,SAASD,QAAQ;AACvB,IAAME,QAAQF,QAAQ;AACtB,IAAMG,SAASH,QAAQ;AAEvB,IAAMI,QAAQJ,QAAQ;AACtB,IAAMK,QAAQL,QAAQ;AACtB,IAAMM,SAAS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MAAM6B,IAAI,CAAC,MAAMP,UAAUH,MAAMF;YAC7CO,MAAME,KAAK,CAACzB,MAAM4B,IAAI,CAAC,MAAMP,UAAUH,MAAMF;YAC7CO,MAAME,KAAK,CAACvB,OAAO0B,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;AAEA9B,UAAUO,SAAS,CAACwB,OAAO,GAAG,SAASA,WAAW;AAElDC,OAAOC,OAAO,GAAGjC"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var path = require("path");
3
+ var assign = require("just-extend");
4
+ var fs = require("graceful-fs");
5
+ var mkpath = require("mkpath");
6
+ var rimraf = require("rimraf");
7
+ var Queue = require("queue-cb");
8
+ var chmod = require("./fs/chmod");
9
+ var chown = require("./fs/chown");
10
+ var utimes = require("./fs/utimes");
11
+ var stripPath = require("./stripPath");
12
+ var validateAttributes = require("./validateAttributes");
13
+ var MANDATORY_ATTRIBUTES = [
14
+ "mode",
15
+ "mtime",
16
+ "path",
17
+ "linkpath"
18
+ ];
19
+ function LinkEntry(attributes, _type) {
20
+ validateAttributes(attributes, MANDATORY_ATTRIBUTES);
21
+ assign(this, attributes);
22
+ if (this.basename === undefined) this.basename = path.basename(this.path);
23
+ if (this.type === undefined) this.type = "link";
24
+ }
25
+ LinkEntry.prototype.create = function create(dest, options, callback) {
26
+ if (typeof options === "function") {
27
+ callback = options;
28
+ options = null;
29
+ }
30
+ var self = this;
31
+ if (typeof callback === "function") {
32
+ options = options || {};
33
+ try {
34
+ var normalizedPath = path.normalize(self.path);
35
+ var fullPath = path.join(dest, stripPath(normalizedPath, options));
36
+ var normalizedLinkpath = path.normalize(self.linkpath);
37
+ var linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));
38
+ var queue = new Queue(1);
39
+ if (options.force) {
40
+ queue.defer(function(callback) {
41
+ rimraf(fullPath, function(err) {
42
+ err && err.code !== "ENOENT" ? callback(err) : callback();
43
+ });
44
+ });
45
+ }
46
+ queue.defer(mkpath.bind(null, path.dirname(fullPath)));
47
+ queue.defer(fs.link.bind(fs, linkFullPath, fullPath));
48
+ queue.defer(chmod.bind(null, fullPath, self, options));
49
+ queue.defer(chown.bind(null, fullPath, self, options));
50
+ queue.defer(utimes.bind(null, fullPath, self, options));
51
+ return queue.await(callback);
52
+ } catch (err) {
53
+ return callback(err);
54
+ }
55
+ }
56
+ return new Promise(function createPromise(resolve, reject) {
57
+ self.create(dest, options, function createCallback(err, done) {
58
+ err ? reject(err) : resolve(done);
59
+ });
60
+ });
61
+ };
62
+ LinkEntry.prototype.destroy = function destroy() {};
63
+ module.exports = LinkEntry;
64
+
65
+ if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
66
+ Object.defineProperty(exports.default, '__esModule', { value: true });
67
+ for (var key in exports) exports.default[key] = exports[key];
68
+ module.exports = exports.default;
69
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["LinkEntry.js"],"sourcesContent":["const path = require('path');\nconst assign = require('just-extend');\nconst fs = require('graceful-fs');\nconst mkpath = require('mkpath');\nconst rimraf = require('rimraf');\nconst Queue = require('queue-cb');\n\nconst chmod = require('./fs/chmod');\nconst chown = require('./fs/chown');\nconst utimes = require('./fs/utimes');\nconst stripPath = require('./stripPath');\nconst validateAttributes = require('./validateAttributes');\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nfunction LinkEntry(attributes, _type) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n 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\nmodule.exports = LinkEntry;\n"],"names":["path","require","assign","fs","mkpath","rimraf","Queue","chmod","chown","utimes","stripPath","validateAttributes","MANDATORY_ATTRIBUTES","LinkEntry","attributes","_type","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","module","exports"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,SAASD,QAAQ;AACvB,IAAME,KAAKF,QAAQ;AACnB,IAAMG,SAASH,QAAQ;AACvB,IAAMI,SAASJ,QAAQ;AACvB,IAAMK,QAAQL,QAAQ;AAEtB,IAAMM,QAAQN,QAAQ;AACtB,IAAMO,QAAQP,QAAQ;AACtB,I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AAI,CAACF,IAAI,CAAClC,IAAI4B,cAAcJ;YAC3CK,MAAME,KAAK,CAAC3B,MAAM8B,IAAI,CAAC,MAAMV,UAAUH,MAAMF;YAC7CU,MAAME,KAAK,CAAC1B,MAAM6B,IAAI,CAAC,MAAMV,UAAUH,MAAMF;YAC7CU,MAAME,KAAK,CAACzB,OAAO4B,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;AAEAjC,UAAUM,SAAS,CAAC4B,OAAO,GAAG,SAASA,WAAW;AAElDC,OAAOC,OAAO,GAAGpC"}
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var path = require("path");
3
+ var assign = require("just-extend");
4
+ var fs = require("graceful-fs");
5
+ var mkpath = require("mkpath");
6
+ var rimraf = require("rimraf");
7
+ var Queue = require("queue-cb");
8
+ var isAbsolute = require("is-absolute");
9
+ var chmod = require("./fs/chmod");
10
+ var chown = require("./fs/chown");
11
+ var utimes = require("./fs/utimes");
12
+ var lstatReal = require("./fs/lstatReal");
13
+ var stripPath = require("./stripPath");
14
+ var validateAttributes = require("./validateAttributes");
15
+ function symlinkWin32(linkFullPath, linkpath, fullPath, callback) {
16
+ lstatReal(linkFullPath, function(err, targetStat) {
17
+ if (err || !targetStat) return callback(err || new Error("Symlink path does not exist".concat(linkFullPath)));
18
+ var type = targetStat.isDirectory() ? "dir" : "file";
19
+ fs.symlink(linkpath, fullPath, type, callback);
20
+ });
21
+ }
22
+ var isWindows = process.platform === "win32";
23
+ var MANDATORY_ATTRIBUTES = [
24
+ "mode",
25
+ "mtime",
26
+ "path",
27
+ "linkpath"
28
+ ];
29
+ function SymbolicLinkEntry(attributes) {
30
+ validateAttributes(attributes, MANDATORY_ATTRIBUTES);
31
+ assign(this, attributes);
32
+ if (this.basename === undefined) this.basename = path.basename(this.path);
33
+ if (this.type === undefined) this.type = "symlink";
34
+ }
35
+ SymbolicLinkEntry.prototype.create = function create(dest, options, callback) {
36
+ if (typeof options === "function") {
37
+ callback = options;
38
+ options = null;
39
+ }
40
+ var self = this;
41
+ if (typeof callback === "function") {
42
+ options = options || {};
43
+ try {
44
+ var normalizedPath = path.normalize(self.path);
45
+ var fullPath = path.join(dest, stripPath(normalizedPath, options));
46
+ var normalizedLinkpath = path.normalize(self.linkpath);
47
+ var linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));
48
+ if (!isAbsolute(normalizedLinkpath)) {
49
+ var linkRelativePath = path.join(path.dirname(normalizedPath), self.linkpath);
50
+ linkFullPath = path.join(dest, stripPath(linkRelativePath, options));
51
+ normalizedLinkpath = path.relative(path.dirname(fullPath), linkFullPath);
52
+ }
53
+ var queue = new Queue(1);
54
+ if (options.force) {
55
+ queue.defer(function(callback) {
56
+ rimraf(fullPath, function(err) {
57
+ err && err.code !== "ENOENT" ? callback(err) : callback();
58
+ });
59
+ });
60
+ }
61
+ queue.defer(mkpath.bind(null, path.dirname(fullPath)));
62
+ if (isWindows) queue.defer(symlinkWin32.bind(null, linkFullPath, normalizedLinkpath, fullPath));
63
+ else queue.defer(fs.symlink.bind(fs, normalizedLinkpath, fullPath));
64
+ queue.defer(chmod.bind(null, fullPath, self, options));
65
+ queue.defer(chown.bind(null, fullPath, self, options));
66
+ queue.defer(utimes.bind(null, fullPath, self, options));
67
+ return queue.await(callback);
68
+ } catch (err) {
69
+ return callback(err);
70
+ }
71
+ }
72
+ return new Promise(function createPromise(resolve, reject) {
73
+ self.create(dest, options, function createCallback(err, done) {
74
+ err ? reject(err) : resolve(done);
75
+ });
76
+ });
77
+ };
78
+ SymbolicLinkEntry.prototype.destroy = function destroy() {};
79
+ module.exports = SymbolicLinkEntry;
80
+
81
+ if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
82
+ Object.defineProperty(exports.default, '__esModule', { value: true });
83
+ for (var key in exports) exports.default[key] = exports[key];
84
+ module.exports = exports.default;
85
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["SymbolicLinkEntry.js"],"sourcesContent":["const path = require('path');\nconst assign = require('just-extend');\nconst fs = require('graceful-fs');\nconst mkpath = require('mkpath');\nconst rimraf = require('rimraf');\nconst Queue = require('queue-cb');\nconst isAbsolute = require('is-absolute');\n\nconst chmod = require('./fs/chmod');\nconst chown = require('./fs/chown');\nconst utimes = require('./fs/utimes');\nconst lstatReal = require('./fs/lstatReal');\nconst stripPath = require('./stripPath');\nconst validateAttributes = require('./validateAttributes');\n\nfunction symlinkWin32(linkFullPath, linkpath, fullPath, callback) {\n lstatReal(linkFullPath, (err, targetStat) => {\n if (err || !targetStat) return callback(err || new Error(`Symlink path does not exist${linkFullPath}`));\n const type = targetStat.isDirectory() ? 'dir' : 'file';\n fs.symlink(linkpath, fullPath, type, callback);\n });\n}\nconst isWindows = process.platform === 'win32';\n\nconst MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];\n\nfunction SymbolicLinkEntry(attributes) {\n validateAttributes(attributes, MANDATORY_ATTRIBUTES);\n assign(this, attributes);\n if (this.basename === undefined) this.basename = path.basename(this.path);\n if (this.type === undefined) this.type = 'symlink';\n}\n\nSymbolicLinkEntry.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 let normalizedLinkpath = path.normalize(self.linkpath);\n let linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));\n if (!isAbsolute(normalizedLinkpath)) {\n const linkRelativePath = path.join(path.dirname(normalizedPath), self.linkpath);\n linkFullPath = path.join(dest, stripPath(linkRelativePath, options));\n normalizedLinkpath = path.relative(path.dirname(fullPath), linkFullPath);\n }\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 if (isWindows) queue.defer(symlinkWin32.bind(null, linkFullPath, normalizedLinkpath, fullPath));\n else queue.defer(fs.symlink.bind(fs, normalizedLinkpath, 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\nSymbolicLinkEntry.prototype.destroy = function destroy() {};\n\nmodule.exports = SymbolicLinkEntry;\n"],"names":["path","require","assign","fs","mkpath","rimraf","Queue","isAbsolute","chmod","chown","utimes","lstatReal","stripPath","validateAttributes","symlinkWin32","linkFullPath","linkpath","fullPath","callback","err","targetStat","Error","type","isDirectory","symlink","isWindows","process","platform","MANDATORY_ATTRIBUTES","SymbolicLinkEntry","attributes","basename","undefined","prototype","create","dest","options","self","normalizedPath","normalize","join","normalizedLinkpath","linkRelativePath","dirname","relative","queue","force","defer","code","bind","await","Promise","createPromise","resolve","reject","createCallback","done","destroy","module","exports"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,SAASD,QAAQ;AACvB,IAAME,KAAKF,QAAQ;AACnB,IAAMG,SAASH,QAAQ;AACvB,IAAMI,SAASJ,QAAQ;AACvB,IAAMK,QAAQL,QAAQ;AACtB,IAAMM,aAAaN,QAAQ;AAE3B,IAAMO,QAAQP,QAAQ;AACtB,IAAMQ,QAA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,EAAEqC,IAAI;YAC1DrC,MAAMmC,OAAOnC,OAAOkC,QAAQG;QAC9B;IACF;AACF;AAEA3B,kBAAkBI,SAAS,CAACwB,OAAO,GAAG,SAASA,WAAW;AAE1DC,OAAOC,OAAO,GAAG9B"}
@@ -0,0 +1,36 @@
1
+ // adapted from https://github.com/mafintosh/tar-fs
2
+ "use strict";
3
+ var fs = require("graceful-fs");
4
+ var UMASK = process.umask ? process.umask() : null;
5
+ var DMODE = parseInt(755, 8);
6
+ var FMODE = parseInt(644, 8);
7
+ var SMODE = parseInt(755, 8);
8
+ var LMODE = parseInt(644, 8);
9
+ module.exports = function chmodFn(fullPath, entry, _options, callback) {
10
+ var chmod = entry.type === "symlink" ? fs.lchmod : fs.chmod;
11
+ if (!chmod || UMASK === null) return callback();
12
+ var mode = entry.mode;
13
+ if (!mode) {
14
+ switch(entry.type){
15
+ case "directory":
16
+ mode = DMODE;
17
+ break;
18
+ case "file":
19
+ mode = FMODE;
20
+ break;
21
+ case "symlink":
22
+ mode = SMODE;
23
+ break;
24
+ case "link":
25
+ mode = LMODE;
26
+ break;
27
+ }
28
+ }
29
+ chmod(fullPath, mode & ~UMASK, callback);
30
+ };
31
+
32
+ if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
33
+ Object.defineProperty(exports.default, '__esModule', { value: true });
34
+ for (var key in exports) exports.default[key] = exports[key];
35
+ module.exports = exports.default;
36
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["chmod.js"],"sourcesContent":["// adapted from https://github.com/mafintosh/tar-fs\n\nconst fs = require('graceful-fs');\n\nconst UMASK = process.umask ? process.umask() : null;\nconst DMODE = parseInt(755, 8);\nconst FMODE = parseInt(644, 8);\nconst SMODE = parseInt(755, 8);\nconst LMODE = parseInt(644, 8);\n\nmodule.exports = function chmodFn(fullPath, entry, _options, callback) {\n const chmod = entry.type === 'symlink' ? fs.lchmod : fs.chmod;\n if (!chmod || UMASK === null) return callback();\n\n let mode = entry.mode;\n if (!mode) {\n switch (entry.type) {\n case 'directory':\n mode = DMODE;\n break;\n case 'file':\n mode = FMODE;\n break;\n case 'symlink':\n mode = SMODE;\n break;\n case 'link':\n mode = LMODE;\n break;\n }\n }\n chmod(fullPath, mode & ~UMASK, callback);\n};\n"],"names":["fs","require","UMASK","process","umask","DMODE","parseInt","FMODE","SMODE","LMODE","module","exports","chmodFn","fullPath","entry","_options","callback","chmod","type","lchmod","mode"],"mappings":"AAAA,mDAAmD;;AAEnD,IAAMA,KAAKC,QAAQ;AAEnB,IAAMC,QAAQC,QAAQC,KAAK,GAAGD,QAAQC,KAAK,KAAK;AAChD,IAAMC,QAAQC,SAAS,KAAK;AAC5B,IAAMC,QAAQD,SAAS,KAAK;AAC5B,IAAME,QAAQF,SAAS,KAAK;AAC5B,IAAMG,QAAQH,SAAS,KAAK;AAE5BI,OAAOC,OAAO,GAAG,SAASC,QAAQC,QAAQ,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ;IACnE,IAAMC,QAAQH,MAAMI,IAAI,KAAK,YAAYlB,GAAGmB,MAAM,GAAGnB,GAAGiB,KAAK;IAC7D,IAAI,CAACA,SAASf,UAAU,MAAM,OAAOc;IAErC,IAAII,OAAON,MAAMM,IAAI;IACrB,IAAI,CAACA,MAAM;QACT,OAAQN,MAAMI,IAAI;YAChB,KAAK;gBACHE,OAAOf;gBACP;YACF,KAAK;gBACHe,OAAOb;gBACP;YACF,KAAK;gBACHa,OAAOZ;gBACP;YACF,KAAK;gBACHY,OAAOX;gBACP;QACJ;IACF;IACAQ,MAAMJ,UAAUO,OAAO,CAAClB,OAAOc;AACjC"}
@@ -0,0 +1,16 @@
1
+ // adapted from https://github.com/mafintosh/tar-fs
2
+ "use strict";
3
+ var fs = require("graceful-fs");
4
+ var UID = process.getuid ? process.getuid() : -1;
5
+ var OWN = process.platform !== "win32" && UID === 0;
6
+ module.exports = function chownFn(fullPath, entry, _options, callback) {
7
+ var chown = entry.type === "symlink" ? fs.lchown : fs.chown;
8
+ if (!chown || !OWN || !entry.uid || !entry.gid) return callback();
9
+ 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
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["chown.js"],"sourcesContent":["// adapted from https://github.com/mafintosh/tar-fs\n\nconst fs = require('graceful-fs');\n\nconst UID = process.getuid ? process.getuid() : -1;\nconst OWN = process.platform !== 'win32' && UID === 0;\n\nmodule.exports = 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":["fs","require","UID","process","getuid","OWN","platform","module","exports","chownFn","fullPath","entry","_options","callback","chown","type","lchown","uid","gid"],"mappings":"AAAA,mDAAmD;;AAEnD,IAAMA,KAAKC,QAAQ;AAEnB,IAAMC,MAAMC,QAAQC,MAAM,GAAGD,QAAQC,MAAM,KAAK,CAAC;AACjD,IAAMC,MAAMF,QAAQG,QAAQ,KAAK,WAAWJ,QAAQ;AAEpDK,OAAOC,OAAO,GAAG,SAASC,QAAQC,QAAQ,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ;IACnE,IAAMC,QAAQH,MAAMI,IAAI,KAAK,YAAYf,GAAGgB,MAAM,GAAGhB,GAAGc,KAAK;IAC7D,IAAI,CAACA,SAAS,CAACT,OAAO,CAACM,MAAMM,GAAG,IAAI,CAACN,MAAMO,GAAG,EAAE,OAAOL;IACvDC,MAAMJ,UAAUC,MAAMM,GAAG,EAAEN,MAAMO,GAAG,EAAEL;AACxC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var fs = require("graceful-fs");
3
+ module.exports = function lstatReal(path, callback) {
4
+ fs.realpath(path, function realpathCallback(err, realpath) {
5
+ err ? callback(err) : fs.lstat(realpath, callback);
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
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["lstatReal.js"],"sourcesContent":["const fs = require('graceful-fs');\n\nmodule.exports = function lstatReal(path, callback) {\n fs.realpath(path, function realpathCallback(err, realpath) {\n err ? callback(err) : fs.lstat(realpath, callback);\n });\n};\n"],"names":["fs","require","module","exports","lstatReal","path","callback","realpath","realpathCallback","err","lstat"],"mappings":";AAAA,IAAMA,KAAKC,QAAQ;AAEnBC,OAAOC,OAAO,GAAG,SAASC,UAAUC,IAAI,EAAEC,QAAQ;IAChDN,GAAGO,QAAQ,CAACF,MAAM,SAASG,iBAAiBC,GAAG,EAAEF,QAAQ;QACvDE,MAAMH,SAASG,OAAOT,GAAGU,KAAK,CAACH,UAAUD;IAC3C;AACF"}
@@ -0,0 +1,13 @@
1
+ // adapted from https://github.com/mafintosh/tar-fs
2
+ "use strict";
3
+ var fs = require("graceful-fs");
4
+ module.exports = function utimes(fullPath, entry, options, callback) {
5
+ var now = options.now || new Date();
6
+ fs.utimes(fullPath, now, new Date(entry.mtime), callback);
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
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["utimes.js"],"sourcesContent":["// adapted from https://github.com/mafintosh/tar-fs\n\nconst fs = require('graceful-fs');\n\nmodule.exports = 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":["fs","require","module","exports","utimes","fullPath","entry","options","callback","now","Date","mtime"],"mappings":"AAAA,mDAAmD;;AAEnD,IAAMA,KAAKC,QAAQ;AAEnBC,OAAOC,OAAO,GAAG,SAASC,OAAOC,QAAQ,EAAEC,KAAK,EAAEC,OAAO,EAAEC,QAAQ;IACjE,IAAMC,MAAMF,QAAQE,GAAG,IAAI,IAAIC;IAC/BV,GAAGI,MAAM,CAACC,UAAUI,KAAK,IAAIC,KAAKJ,MAAMK,KAAK,GAAGH;AAClD"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var access = require("fs-access-compat");
3
+ function waitForAccess(fullPath, callback) {
4
+ access(fullPath, function(err) {
5
+ if (err) return waitForAccess(fullPath, callback);
6
+ callback();
7
+ });
8
+ }
9
+ module.exports = waitForAccess;
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
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["waitForAccess.js"],"sourcesContent":["const access = require('fs-access-compat');\n\nfunction waitForAccess(fullPath, callback) {\n access(fullPath, (err) => {\n if (err) return waitForAccess(fullPath, callback);\n callback();\n });\n}\n\nmodule.exports = waitForAccess;\n"],"names":["access","require","waitForAccess","fullPath","callback","err","module","exports"],"mappings":";AAAA,IAAMA,SAASC,QAAQ;AAEvB,SAASC,cAAcC,QAAQ,EAAEC,QAAQ;IACvCJ,OAAOG,UAAU,SAACE;QAChB,IAAIA,KAAK,OAAOH,cAAcC,UAAUC;QACxCA;IACF;AACF;AAEAE,OAAOC,OAAO,GAAGL"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ module.exports = require("stack-base-iterator");
3
+ module.exports.DirectoryEntry = require("./DirectoryEntry");
4
+ module.exports.FileEntry = require("./FileEntry");
5
+ module.exports.LinkEntry = require("./LinkEntry");
6
+ module.exports.SymbolicLinkEntry = require("./SymbolicLinkEntry");
7
+
8
+ if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
9
+ Object.defineProperty(exports.default, '__esModule', { value: true });
10
+ for (var key in exports) exports.default[key] = exports[key];
11
+ module.exports = exports.default;
12
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["module.exports = require('stack-base-iterator');\nmodule.exports.DirectoryEntry = require('./DirectoryEntry');\nmodule.exports.FileEntry = require('./FileEntry');\nmodule.exports.LinkEntry = require('./LinkEntry');\nmodule.exports.SymbolicLinkEntry = require('./SymbolicLinkEntry');\n"],"names":["module","exports","require","DirectoryEntry","FileEntry","LinkEntry","SymbolicLinkEntry"],"mappings":";AAAAA,OAAOC,OAAO,GAAGC,QAAQ;AACzBF,OAAOC,OAAO,CAACE,cAAc,GAAGD,QAAQ;AACxCF,OAAOC,OAAO,CAACG,SAAS,GAAGF,QAAQ;AACnCF,OAAOC,OAAO,CAACI,SAAS,GAAGH,QAAQ;AACnCF,OAAOC,OAAO,CAACK,iBAAiB,GAAGJ,QAAQ"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var path = require("path");
3
+ var compact = require("lodash.compact");
4
+ module.exports = function stripPath(relativePath, options) {
5
+ var strip = options.strip || 0;
6
+ if (!strip) return relativePath;
7
+ var parts = compact(relativePath.split(path.sep));
8
+ 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(path.sep);
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
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["stripPath.js"],"sourcesContent":["const path = require('path');\nconst compact = require('lodash.compact');\n\nmodule.exports = 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":["path","require","compact","module","exports","stripPath","relativePath","options","strip","parts","split","sep","length","Error","slice","join"],"mappings":";AAAA,IAAMA,OAAOC,QAAQ;AACrB,IAAMC,UAAUD,QAAQ;AAExBE,OAAOC,OAAO,GAAG,SAASC,UAAUC,YAAY,EAAEC,OAAO;IACvD,IAAMC,QAAQD,QAAQC,KAAK,IAAI;IAC/B,IAAI,CAACA,OAAO,OAAOF;IACnB,IAAMG,QAAQP,QAAQI,aAAaI,KAAK,CAACV,KAAKW,GAAG;IACjD,IAAIF,MAAMG,MAAM,GAAGJ,OAAO,MAAM,IAAIK,MAAM,AAAC,mEAAkFP,OAAhBE,OAAM,YAAuB,OAAbF;IAC7H,OAAOG,MAAMK,KAAK,CAACN,OAAOO,IAAI,CAACf,KAAKW,GAAG;AACzC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ module.exports = function validateAttributes(attributes, keys) {
3
+ var key;
4
+ for(var index = 0; index < keys.length; index++){
5
+ key = keys[index];
6
+ if (attributes[key] === undefined) throw new Error("Missing attribute ".concat(key, ".Attributes ").concat(JSON.stringify(attributes)));
7
+ }
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
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["validateAttributes.js"],"sourcesContent":["module.exports = 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":["module","exports","validateAttributes","attributes","keys","key","index","length","undefined","Error","JSON","stringify"],"mappings":";AAAAA,OAAOC,OAAO,GAAG,SAASC,mBAAmBC,UAAU,EAAEC,IAAI;IAC3D,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,9 @@
1
+ export = DirectoryEntry;
2
+ declare function DirectoryEntry(attributes: any): void;
3
+ declare class DirectoryEntry {
4
+ constructor(attributes: any);
5
+ type: string;
6
+ basename: string;
7
+ create(dest: any, options: any, callback: any): any;
8
+ destroy(): void;
9
+ }
@@ -0,0 +1,9 @@
1
+ export = FileEntry;
2
+ declare function FileEntry(attributes: any): void;
3
+ declare class FileEntry {
4
+ constructor(attributes: any);
5
+ basename: string;
6
+ type: string;
7
+ create(dest: any, options: any, callback: any): any;
8
+ destroy(): void;
9
+ }
@@ -0,0 +1,9 @@
1
+ export = LinkEntry;
2
+ declare function LinkEntry(attributes: any, _type: any): void;
3
+ declare class LinkEntry {
4
+ constructor(attributes: any, _type: any);
5
+ basename: string;
6
+ type: string;
7
+ create(dest: any, options: any, callback: any): any;
8
+ destroy(): void;
9
+ }
@@ -0,0 +1,9 @@
1
+ export = SymbolicLinkEntry;
2
+ declare function SymbolicLinkEntry(attributes: any): void;
3
+ declare class SymbolicLinkEntry {
4
+ constructor(attributes: any);
5
+ basename: string;
6
+ type: string;
7
+ create(dest: any, options: any, callback: any): any;
8
+ destroy(): void;
9
+ }
@@ -0,0 +1,2 @@
1
+ declare function _exports(fullPath: any, entry: any, _options: any, callback: any): any;
2
+ export = _exports;
@@ -0,0 +1,2 @@
1
+ declare function _exports(fullPath: any, entry: any, _options: any, callback: any): any;
2
+ export = _exports;
@@ -0,0 +1,2 @@
1
+ declare function _exports(path: any, callback: any): void;
2
+ export = _exports;
@@ -0,0 +1,2 @@
1
+ declare function _exports(fullPath: any, entry: any, options: any, callback: any): void;
2
+ export = _exports;
@@ -0,0 +1,2 @@
1
+ export = waitForAccess;
2
+ declare function waitForAccess(fullPath: any, callback: any): void;
@@ -0,0 +1,6 @@
1
+ declare const _exports: any;
2
+ export = _exports;
3
+ export const DirectoryEntry: typeof import("./DirectoryEntry");
4
+ export const FileEntry: typeof import("./FileEntry");
5
+ export const LinkEntry: typeof import("./LinkEntry");
6
+ export const SymbolicLinkEntry: typeof import("./SymbolicLinkEntry");
@@ -0,0 +1,2 @@
1
+ declare function _exports(relativePath: any, options: any): any;
2
+ export = _exports;
@@ -0,0 +1,2 @@
1
+ declare function _exports(attributes: any, keys: any): void;
2
+ export = _exports;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extract-base-iterator",
3
- "version": "0.2.5",
3
+ "version": "0.3.0",
4
4
  "description": "Base iterator for extract iterators like tar-iterator and zip-iterator",
5
5
  "keywords": [
6
6
  "extract",
@@ -20,44 +20,49 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "author": "Kevin Malakoff <kmalakoff@gmail.com> (https://github.com/kmalakoff)",
23
- "main": "index.js",
23
+ "main": "dist/cjs/index.js",
24
+ "types": "dist/types/index.d.ts",
25
+ "files": [
26
+ "dist"
27
+ ],
24
28
  "scripts": {
25
- "format": "prettier --write .",
26
- "lint": "eslint .",
27
- "prepublishOnly": "dtd \"npm run lint\" \"depcheck\"",
28
- "test": "mocha-compat test/spec/**/*.test.js --no-timeouts"
29
+ "build": "tsds build",
30
+ "deploy": "tsds deploy",
31
+ "format": "biome check --apply-unsafe src/ test/",
32
+ "test": "tsds test:node --timeout=10000",
33
+ "test:engines": "nvu engines npm test",
34
+ "version": "tsds version"
29
35
  },
30
36
  "dependencies": {
31
- "fs-access-compat": "^1.0.2",
32
- "graceful-fs": "^4.2.4",
37
+ "fs-access-compat": "^1.0.3",
38
+ "graceful-fs": "^4.2.11",
33
39
  "inherits": "^2.0.4",
34
40
  "is-absolute": "^1.0.0",
41
+ "just-extend": "^6.2.0",
35
42
  "lodash.compact": "^3.0.1",
36
43
  "mkpath": "^1.0.0",
37
- "object-assign": "^4.1.1",
38
- "queue-cb": "^1.1.5",
44
+ "queue-cb": "^1.1.7",
39
45
  "rimraf": "^2.7.1",
40
- "stack-base-iterator": "^0.1.5"
46
+ "stack-base-iterator": "^1.0.0"
41
47
  },
42
48
  "devDependencies": {
43
- "babel-eslint": "^10.1.0",
49
+ "@biomejs/biome": "^1.5.3",
50
+ "@types/mocha": "^10.0.6",
51
+ "@types/node": "^20.11.19",
44
52
  "cr": "^0.1.0",
45
- "depcheck": "^0.9.2",
46
- "dis-dat": "^0.1.3",
47
- "eslint": "^6.8.0",
48
- "eslint-config-prettier": "^6.11.0",
49
- "eslint-config-standard": "^14.1.1",
50
- "eslint-plugin-import": "^2.22.0",
51
- "eslint-plugin-node": "^11.1.0",
52
- "eslint-plugin-promise": "^4.2.1",
53
- "eslint-plugin-standard": "^4.0.1",
54
- "fs-iterator": "^4.0.2",
55
- "fs-stats-spys": "^1.0.1",
53
+ "depcheck": "^1.4.7",
54
+ "fs-iterator": "^4.1.1",
55
+ "fs-stats-spys": "^1.0.2",
56
56
  "lodash.find": "^4.6.0",
57
- "mocha-compat": "^3.5.5",
58
- "prettier": "^2.0.5"
57
+ "ts-dev-stack": "^0.13.0"
59
58
  },
60
59
  "engines": {
61
60
  "node": ">=0.8"
61
+ },
62
+ "tsds": {
63
+ "source": "src/index.js",
64
+ "targets": [
65
+ "cjs"
66
+ ]
62
67
  }
63
68
  }
package/index.js DELETED
@@ -1,5 +0,0 @@
1
- module.exports = require('stack-base-iterator');
2
- module.exports.DirectoryEntry = require('./lib/DirectoryEntry');
3
- module.exports.FileEntry = require('./lib/FileEntry');
4
- module.exports.LinkEntry = require('./lib/LinkEntry');
5
- module.exports.SymbolicLinkEntry = require('./lib/SymbolicLinkEntry');
@@ -1,55 +0,0 @@
1
- var path = require('path');
2
- var mkpath = require('mkpath');
3
- var Queue = require('queue-cb');
4
- var assign = require('object-assign');
5
-
6
- var chmod = require('./fs/chmod');
7
- var chown = require('./fs/chown');
8
- var utimes = require('./fs/utimes');
9
- var stripPath = require('./stripPath');
10
- var validateAttributes = require('./validateAttributes');
11
-
12
- var MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];
13
-
14
- function DirectoryEntry(attributes) {
15
- validateAttributes(attributes, MANDATORY_ATTRIBUTES);
16
- assign(this, attributes);
17
- if (this.type === undefined) this.type = 'directory';
18
- if (this.basename === undefined) this.basename = path.basename(this.path);
19
- }
20
-
21
- DirectoryEntry.prototype.create = function create(dest, options, callback) {
22
- if (typeof options === 'function') {
23
- callback = options;
24
- options = null;
25
- }
26
-
27
- var self = this;
28
- if (typeof callback === 'function') {
29
- options = options || {};
30
- try {
31
- var normalizedPath = path.normalize(self.path);
32
- var fullPath = path.join(dest, stripPath(normalizedPath, options));
33
-
34
- // do not check for the existence of the directory but allow out-of-order calling
35
- var queue = new Queue(1);
36
- queue.defer(mkpath.bind(null, fullPath));
37
- queue.defer(chmod.bind(null, fullPath, self, options));
38
- queue.defer(chown.bind(null, fullPath, self, options));
39
- queue.defer(utimes.bind(null, fullPath, self, options));
40
- return queue.await(callback);
41
- } catch (err) {
42
- return callback(err);
43
- }
44
- }
45
-
46
- return new Promise(function createPromise(resolve, reject) {
47
- self.create(dest, options, function createCallback(err, done) {
48
- err ? reject(err) : resolve(done);
49
- });
50
- });
51
- };
52
-
53
- DirectoryEntry.prototype.destroy = function destroy() {};
54
-
55
- module.exports = DirectoryEntry;
package/lib/FileEntry.js DELETED
@@ -1,64 +0,0 @@
1
- var path = require('path');
2
- var mkpath = require('mkpath');
3
- var Queue = require('queue-cb');
4
- var assign = require('object-assign');
5
-
6
- var chmod = require('./fs/chmod');
7
- var chown = require('./fs/chown');
8
- var rimraf = require('rimraf');
9
- var utimes = require('./fs/utimes');
10
- var stripPath = require('./stripPath');
11
- var validateAttributes = require('./validateAttributes');
12
-
13
- var MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path'];
14
-
15
- function FileEntry(attributes) {
16
- validateAttributes(attributes, MANDATORY_ATTRIBUTES);
17
- 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
-
23
- FileEntry.prototype.create = function create(dest, options, callback) {
24
- if (typeof options === 'function') {
25
- callback = options;
26
- options = null;
27
- }
28
-
29
- var self = this;
30
- if (typeof callback === 'function') {
31
- options = options || {};
32
- try {
33
- var normalizedPath = path.normalize(self.path);
34
- var fullPath = path.join(dest, stripPath(normalizedPath, options));
35
-
36
- var queue = new Queue(1);
37
- if (options.force) {
38
- queue.defer(function (callback) {
39
- rimraf(fullPath, function (err) {
40
- err && err.code !== 'ENOENT' ? callback(err) : callback();
41
- });
42
- });
43
- }
44
- queue.defer(mkpath.bind(null, path.dirname(fullPath)));
45
- queue.defer(this._writeFile.bind(this, fullPath, options));
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
-
55
- return new Promise(function createPromise(resolve, reject) {
56
- self.create(dest, options, function createCallback(err, done) {
57
- err ? reject(err) : resolve(done);
58
- });
59
- });
60
- };
61
-
62
- FileEntry.prototype.destroy = function destroy() {};
63
-
64
- module.exports = FileEntry;
package/lib/LinkEntry.js DELETED
@@ -1,66 +0,0 @@
1
- var path = require('path');
2
- var assign = require('object-assign');
3
- var fs = require('graceful-fs');
4
- var mkpath = require('mkpath');
5
- var rimraf = require('rimraf');
6
- var Queue = require('queue-cb');
7
-
8
- var chmod = require('./fs/chmod');
9
- var chown = require('./fs/chown');
10
- var utimes = require('./fs/utimes');
11
- var stripPath = require('./stripPath');
12
- var validateAttributes = require('./validateAttributes');
13
-
14
- var MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];
15
-
16
- function LinkEntry(attributes, type) {
17
- validateAttributes(attributes, MANDATORY_ATTRIBUTES);
18
- assign(this, attributes);
19
- if (this.basename === undefined) this.basename = path.basename(this.path);
20
- if (this.type === undefined) this.type = 'link';
21
- }
22
-
23
- LinkEntry.prototype.create = function create(dest, options, callback) {
24
- if (typeof options === 'function') {
25
- callback = options;
26
- options = null;
27
- }
28
-
29
- var self = this;
30
- if (typeof callback === 'function') {
31
- options = options || {};
32
- try {
33
- var normalizedPath = path.normalize(self.path);
34
- var fullPath = path.join(dest, stripPath(normalizedPath, options));
35
- var normalizedLinkpath = path.normalize(self.linkpath);
36
- var linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));
37
-
38
- var queue = new Queue(1);
39
- if (options.force) {
40
- queue.defer(function (callback) {
41
- rimraf(fullPath, function (err) {
42
- err && err.code !== 'ENOENT' ? callback(err) : callback();
43
- });
44
- });
45
- }
46
- queue.defer(mkpath.bind(null, path.dirname(fullPath)));
47
- queue.defer(fs.link.bind(fs, linkFullPath, fullPath));
48
- queue.defer(chmod.bind(null, fullPath, self, options));
49
- queue.defer(chown.bind(null, fullPath, self, options));
50
- queue.defer(utimes.bind(null, fullPath, self, options));
51
- return queue.await(callback);
52
- } catch (err) {
53
- return callback(err);
54
- }
55
- }
56
-
57
- return new Promise(function createPromise(resolve, reject) {
58
- self.create(dest, options, function createCallback(err, done) {
59
- err ? reject(err) : resolve(done);
60
- });
61
- });
62
- };
63
-
64
- LinkEntry.prototype.destroy = function destroy() {};
65
-
66
- module.exports = LinkEntry;
@@ -1,83 +0,0 @@
1
- var path = require('path');
2
- var assign = require('object-assign');
3
- var fs = require('graceful-fs');
4
- var mkpath = require('mkpath');
5
- var rimraf = require('rimraf');
6
- var Queue = require('queue-cb');
7
- var isAbsolute = require('is-absolute');
8
-
9
- var chmod = require('./fs/chmod');
10
- var chown = require('./fs/chown');
11
- var utimes = require('./fs/utimes');
12
- var lstatReal = require('./fs/lstatReal');
13
- var stripPath = require('./stripPath');
14
- var validateAttributes = require('./validateAttributes');
15
-
16
- function symlinkWin32(linkFullPath, linkpath, fullPath, callback) {
17
- lstatReal(linkFullPath, function (err, targetStat) {
18
- if (err || !targetStat) return callback(err || new Error('Symlink path does not exist' + linkFullPath));
19
- var type = targetStat.isDirectory() ? 'dir' : 'file';
20
- fs.symlink(linkpath, fullPath, type, callback);
21
- });
22
- }
23
- var isWindows = process.platform === 'win32';
24
-
25
- var MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];
26
-
27
- function SymbolicLinkEntry(attributes) {
28
- validateAttributes(attributes, MANDATORY_ATTRIBUTES);
29
- assign(this, attributes);
30
- if (this.basename === undefined) this.basename = path.basename(this.path);
31
- if (this.type === undefined) this.type = 'symlink';
32
- }
33
-
34
- SymbolicLinkEntry.prototype.create = function create(dest, options, callback) {
35
- if (typeof options === 'function') {
36
- callback = options;
37
- options = null;
38
- }
39
-
40
- var self = this;
41
- if (typeof callback === 'function') {
42
- options = options || {};
43
- try {
44
- var normalizedPath = path.normalize(self.path);
45
- var fullPath = path.join(dest, stripPath(normalizedPath, options));
46
- var normalizedLinkpath = path.normalize(self.linkpath);
47
- var linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));
48
- if (!isAbsolute(normalizedLinkpath)) {
49
- var linkRelativePath = path.join(path.dirname(normalizedPath), self.linkpath);
50
- linkFullPath = path.join(dest, stripPath(linkRelativePath, options));
51
- normalizedLinkpath = path.relative(path.dirname(fullPath), linkFullPath);
52
- }
53
-
54
- var queue = new Queue(1);
55
- if (options.force) {
56
- queue.defer(function (callback) {
57
- rimraf(fullPath, function (err) {
58
- err && err.code !== 'ENOENT' ? callback(err) : callback();
59
- });
60
- });
61
- }
62
- queue.defer(mkpath.bind(null, path.dirname(fullPath)));
63
- if (isWindows) queue.defer(symlinkWin32.bind(null, linkFullPath, normalizedLinkpath, fullPath));
64
- else queue.defer(fs.symlink.bind(fs, normalizedLinkpath, fullPath));
65
- queue.defer(chmod.bind(null, fullPath, self, options));
66
- queue.defer(chown.bind(null, fullPath, self, options));
67
- queue.defer(utimes.bind(null, fullPath, self, options));
68
- return queue.await(callback);
69
- } catch (err) {
70
- return callback(err);
71
- }
72
- }
73
-
74
- return new Promise(function createPromise(resolve, reject) {
75
- self.create(dest, options, function createCallback(err, done) {
76
- err ? reject(err) : resolve(done);
77
- });
78
- });
79
- };
80
-
81
- SymbolicLinkEntry.prototype.destroy = function destroy() {};
82
-
83
- module.exports = SymbolicLinkEntry;
package/lib/fs/chmod.js DELETED
@@ -1,34 +0,0 @@
1
- // adapted from https://github.com/mafintosh/tar-fs
2
-
3
- var fs = require('graceful-fs');
4
-
5
- var UMASK = process.umask ? process.umask() : null;
6
- var DMODE = parseInt(755, 8);
7
- var FMODE = parseInt(644, 8);
8
- var SMODE = parseInt(755, 8);
9
- var LMODE = parseInt(644, 8);
10
-
11
- module.exports = function chmodFn(fullPath, entry, options, callback) {
12
- // eslint-disable-next-line node/no-deprecated-api
13
- var chmod = entry.type === 'symlink' ? fs.lchmod : fs.chmod;
14
- if (!chmod || UMASK === null) return callback();
15
-
16
- var mode = entry.mode;
17
- if (!mode) {
18
- switch (entry.type) {
19
- case 'directory':
20
- mode = DMODE;
21
- break;
22
- case 'file':
23
- mode = FMODE;
24
- break;
25
- case 'symlink':
26
- mode = SMODE;
27
- break;
28
- case 'link':
29
- mode = LMODE;
30
- break;
31
- }
32
- }
33
- chmod(fullPath, mode & ~UMASK, callback);
34
- };
package/lib/fs/chown.js DELETED
@@ -1,12 +0,0 @@
1
- // adapted from https://github.com/mafintosh/tar-fs
2
-
3
- var fs = require('graceful-fs');
4
-
5
- var UID = process.getuid ? process.getuid() : -1;
6
- var OWN = process.platform !== 'win32' && UID === 0;
7
-
8
- module.exports = function chownFn(fullPath, entry, options, callback) {
9
- var chown = entry.type === 'symlink' ? fs.lchown : fs.chown;
10
- if (!chown || !OWN || !entry.uid || !entry.gid) return callback();
11
- chown(fullPath, entry.uid, entry.gid, callback);
12
- };
@@ -1,7 +0,0 @@
1
- var fs = require('graceful-fs');
2
-
3
- module.exports = function lstatReal(path, callback) {
4
- fs.realpath(path, function realpathCallback(err, realpath) {
5
- err ? callback(err) : fs.lstat(realpath, callback);
6
- });
7
- };
package/lib/fs/utimes.js DELETED
@@ -1,8 +0,0 @@
1
- // adapted from https://github.com/mafintosh/tar-fs
2
-
3
- var fs = require('graceful-fs');
4
-
5
- module.exports = function utimes(fullPath, entry, options, callback) {
6
- var now = options.now || new Date();
7
- fs.utimes(fullPath, now, new Date(entry.mtime), callback);
8
- };
@@ -1,10 +0,0 @@
1
- var access = require('fs-access-compat');
2
-
3
- function waitForAccess(fullPath, callback) {
4
- access(fullPath, function (err) {
5
- if (err) return waitForAccess(fullPath, callback);
6
- callback();
7
- });
8
- }
9
-
10
- module.exports = waitForAccess;
package/lib/stripPath.js DELETED
@@ -1,10 +0,0 @@
1
- var path = require('path');
2
- var compact = require('lodash.compact');
3
-
4
- module.exports = function stripPath(relativePath, options) {
5
- var strip = options.strip || 0;
6
- if (!strip) return relativePath;
7
- var parts = compact(relativePath.split(path.sep));
8
- if (parts.length < strip) throw new Error('You cannot strip more levels than there are directories. Strip: ' + strip + '. Path: ' + relativePath);
9
- return parts.slice(strip).join(path.sep);
10
- };
@@ -1,7 +0,0 @@
1
- module.exports = function validateAttributes(attributes, keys) {
2
- var key;
3
- for (var index = 0; index < keys.length; index++) {
4
- key = keys[index];
5
- if (attributes[key] === undefined) throw new Error('Missing attribute ' + key + '.Attributes ' + JSON.stringify(attributes));
6
- }
7
- };