extract-base-iterator 0.2.3 → 0.2.6

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.
@@ -1,7 +1,7 @@
1
1
  var path = require('path');
2
2
  var mkpath = require('mkpath');
3
3
  var Queue = require('queue-cb');
4
- var assign = require('object-assign');
4
+ var assign = require('just-extend');
5
5
 
6
6
  var chmod = require('./fs/chmod');
7
7
  var chown = require('./fs/chown');
@@ -31,12 +31,9 @@ DirectoryEntry.prototype.create = function create(dest, options, callback) {
31
31
  var normalizedPath = path.normalize(self.path);
32
32
  var fullPath = path.join(dest, stripPath(normalizedPath, options));
33
33
 
34
+ // do not check for the existence of the directory but allow out-of-order calling
34
35
  var queue = new Queue(1);
35
- queue.defer(function (callback) {
36
- mkpath(fullPath, function (err) {
37
- err && err.code !== 'EEXIST' ? callback(err) : callback();
38
- });
39
- });
36
+ queue.defer(mkpath.bind(null, fullPath));
40
37
  queue.defer(chmod.bind(null, fullPath, self, options));
41
38
  queue.defer(chown.bind(null, fullPath, self, options));
42
39
  queue.defer(utimes.bind(null, fullPath, self, options));
package/lib/FileEntry.js CHANGED
@@ -1,7 +1,7 @@
1
1
  var path = require('path');
2
2
  var mkpath = require('mkpath');
3
3
  var Queue = require('queue-cb');
4
- var assign = require('object-assign');
4
+ var assign = require('just-extend');
5
5
 
6
6
  var chmod = require('./fs/chmod');
7
7
  var chown = require('./fs/chown');
@@ -34,16 +34,14 @@ FileEntry.prototype.create = function create(dest, options, callback) {
34
34
  var fullPath = path.join(dest, stripPath(normalizedPath, options));
35
35
 
36
36
  var queue = new Queue(1);
37
- queue.defer(function (callback) {
38
- mkpath(path.dirname(fullPath), function (err) {
39
- err && err.code !== 'EEXIST' ? callback(err) : callback();
37
+ if (options.force) {
38
+ queue.defer(function (callback) {
39
+ rimraf(fullPath, function (err) {
40
+ err && err.code !== 'ENOENT' ? callback(err) : callback();
41
+ });
40
42
  });
41
- });
42
- queue.defer(function (callback) {
43
- rimraf(fullPath, function (err) {
44
- err && err.code !== 'ENOENT' ? callback(err) : callback();
45
- });
46
- });
43
+ }
44
+ queue.defer(mkpath.bind(null, path.dirname(fullPath)));
47
45
  queue.defer(this._writeFile.bind(this, fullPath, options));
48
46
  queue.defer(chmod.bind(null, fullPath, self, options));
49
47
  queue.defer(chown.bind(null, fullPath, self, options));
package/lib/LinkEntry.js CHANGED
@@ -1,5 +1,5 @@
1
1
  var path = require('path');
2
- var assign = require('object-assign');
2
+ var assign = require('just-extend');
3
3
  var fs = require('graceful-fs');
4
4
  var mkpath = require('mkpath');
5
5
  var rimraf = require('rimraf');
@@ -36,16 +36,14 @@ LinkEntry.prototype.create = function create(dest, options, callback) {
36
36
  var linkFullPath = path.join(dest, stripPath(normalizedLinkpath, options));
37
37
 
38
38
  var queue = new Queue(1);
39
- queue.defer(function (callback) {
40
- rimraf(fullPath, function (err) {
41
- err && err.code !== 'ENOENT' ? callback(err) : callback();
39
+ if (options.force) {
40
+ queue.defer(function (callback) {
41
+ rimraf(fullPath, function (err) {
42
+ err && err.code !== 'ENOENT' ? callback(err) : callback();
43
+ });
42
44
  });
43
- });
44
- queue.defer(function (callback) {
45
- mkpath(path.dirname(fullPath), function (err) {
46
- err && err.code !== 'EEXIST' ? callback(err) : callback();
47
- });
48
- });
45
+ }
46
+ queue.defer(mkpath.bind(null, path.dirname(fullPath)));
49
47
  queue.defer(fs.link.bind(fs, linkFullPath, fullPath));
50
48
  queue.defer(chmod.bind(null, fullPath, self, options));
51
49
  queue.defer(chown.bind(null, fullPath, self, options));
@@ -1,5 +1,5 @@
1
1
  var path = require('path');
2
- var assign = require('object-assign');
2
+ var assign = require('just-extend');
3
3
  var fs = require('graceful-fs');
4
4
  var mkpath = require('mkpath');
5
5
  var rimraf = require('rimraf');
@@ -24,11 +24,11 @@ var isWindows = process.platform === 'win32';
24
24
 
25
25
  var MANDATORY_ATTRIBUTES = ['mode', 'mtime', 'path', 'linkpath'];
26
26
 
27
- function SymbolicLinkEntry(attributes, type) {
27
+ function SymbolicLinkEntry(attributes) {
28
28
  validateAttributes(attributes, MANDATORY_ATTRIBUTES);
29
29
  assign(this, attributes);
30
30
  if (this.basename === undefined) this.basename = path.basename(this.path);
31
- if (this.type === undefined) this.type = 'link';
31
+ if (this.type === undefined) this.type = 'symlink';
32
32
  }
33
33
 
34
34
  SymbolicLinkEntry.prototype.create = function create(dest, options, callback) {
@@ -52,17 +52,14 @@ SymbolicLinkEntry.prototype.create = function create(dest, options, callback) {
52
52
  }
53
53
 
54
54
  var queue = new Queue(1);
55
- queue.defer(function (callback) {
56
- rimraf(fullPath, function (err) {
57
- err && err.code !== 'ENOENT' ? callback(err) : callback();
55
+ if (options.force) {
56
+ queue.defer(function (callback) {
57
+ rimraf(fullPath, function (err) {
58
+ err && err.code !== 'ENOENT' ? callback(err) : callback();
59
+ });
58
60
  });
59
- });
60
- queue.defer(function (callback) {
61
- mkpath(path.dirname(fullPath), function (err) {
62
- err && err.code !== 'EEXIST' ? callback(err) : callback();
63
- });
64
- });
65
-
61
+ }
62
+ queue.defer(mkpath.bind(null, path.dirname(fullPath)));
66
63
  if (isWindows) queue.defer(symlinkWin32.bind(null, linkFullPath, normalizedLinkpath, fullPath));
67
64
  else queue.defer(fs.symlink.bind(fs, normalizedLinkpath, fullPath));
68
65
  queue.defer(chmod.bind(null, fullPath, self, options));
package/lib/fs/chmod.js CHANGED
@@ -2,15 +2,33 @@
2
2
 
3
3
  var fs = require('graceful-fs');
4
4
 
5
- var UMASK = process.umask ? process.umask() : 0;
6
- var DMODE = parseInt(333, 8);
7
- var FMODE = parseInt(222, 8);
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);
8
10
 
9
11
  module.exports = function chmodFn(fullPath, entry, options, callback) {
10
- // eslint-disable-next-line node/no-deprecated-api
12
+ // eslint-disable-next-line n/no-deprecated-api
11
13
  var chmod = entry.type === 'symlink' ? fs.lchmod : fs.chmod;
12
14
  if (!chmod || UMASK === null) return callback();
13
15
 
14
- var mode = (entry.mode | (entry.type === 'directory' ? DMODE : FMODE)) & ~UMASK;
15
- chmod(fullPath, mode, callback);
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);
16
34
  };
package/lib/index.js ADDED
@@ -0,0 +1,5 @@
1
+ module.exports = require('stack-base-iterator');
2
+ module.exports.DirectoryEntry = require('./DirectoryEntry');
3
+ module.exports.FileEntry = require('./FileEntry');
4
+ module.exports.LinkEntry = require('./LinkEntry');
5
+ module.exports.SymbolicLinkEntry = require('./SymbolicLinkEntry');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extract-base-iterator",
3
- "version": "0.2.3",
3
+ "version": "0.2.6",
4
4
  "description": "Base iterator for extract iterators like tar-iterator and zip-iterator",
5
5
  "keywords": [
6
6
  "extract",
@@ -20,7 +20,10 @@
20
20
  },
21
21
  "license": "MIT",
22
22
  "author": "Kevin Malakoff <kmalakoff@gmail.com> (https://github.com/kmalakoff)",
23
- "main": "index.js",
23
+ "main": "lib/index.js",
24
+ "files": [
25
+ "lib"
26
+ ],
24
27
  "scripts": {
25
28
  "format": "prettier --write .",
26
29
  "lint": "eslint .",
@@ -28,37 +31,33 @@
28
31
  "test": "mocha-compat test/spec/**/*.test.js --no-timeouts"
29
32
  },
30
33
  "dependencies": {
31
- "fs-access-compat": "^1.0.1",
32
- "graceful-fs": "^4.2.4",
34
+ "fs-access-compat": "^1.0.2",
35
+ "graceful-fs": "^4.2.10",
33
36
  "inherits": "^2.0.4",
34
37
  "is-absolute": "^1.0.0",
38
+ "just-extend": "^6.0.1",
35
39
  "lodash.compact": "^3.0.1",
36
40
  "mkpath": "^1.0.0",
37
- "object-assign": "^4.1.1",
38
- "queue-cb": "^1.1.5",
41
+ "queue-cb": "^1.1.6",
39
42
  "rimraf": "^2.7.1",
40
- "stack-base-iterator": "^0.1.5"
43
+ "stack-base-iterator": "^0.1.7"
41
44
  },
42
45
  "devDependencies": {
43
- "babel-eslint": "^10.1.0",
44
- "big-int-stats": "^1.2.1",
46
+ "@typescript-eslint/parser": "^5.30.0",
45
47
  "cr": "^0.1.0",
46
- "depcheck": "^0.9.2",
47
- "dis-dat": "^0.1.3",
48
- "eslint": "^6.8.0",
49
- "eslint-config-prettier": "^6.11.0",
50
- "eslint-config-standard": "^14.1.1",
51
- "eslint-plugin-import": "^2.21.2",
52
- "eslint-plugin-node": "^11.1.0",
53
- "eslint-plugin-promise": "^4.2.1",
54
- "eslint-plugin-standard": "^4.0.1",
55
- "fs-generate": "^1.8.4",
56
- "fs-iterator": "^4.0.1",
48
+ "depcheck": "^1.4.3",
49
+ "dis-dat": "^0.1.6",
50
+ "eslint": "^8.18.0",
51
+ "eslint-config-prettier": "^8.5.0",
52
+ "eslint-config-standard": "^17.0.0",
53
+ "eslint-plugin-import": "^2.26.0",
54
+ "eslint-plugin-n": "^15.2.3",
55
+ "eslint-plugin-promise": "^6.0.0",
56
+ "fs-iterator": "^4.1.1",
57
57
  "fs-stats-spys": "^1.0.1",
58
58
  "lodash.find": "^4.6.0",
59
59
  "mocha-compat": "^3.5.5",
60
- "normalize-stats": "^1.0.0",
61
- "prettier": "^2.0.5"
60
+ "prettier": "^2.7.1"
62
61
  },
63
62
  "engines": {
64
63
  "node": ">=0.8"
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');