tar 6.2.1 → 7.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/README.md +30 -16
- package/dist/commonjs/create.d.ts +8 -0
- package/dist/commonjs/create.d.ts.map +1 -0
- package/dist/commonjs/create.js +106 -0
- package/dist/commonjs/create.js.map +1 -0
- package/dist/commonjs/cwd-error.d.ts +8 -0
- package/dist/commonjs/cwd-error.d.ts.map +1 -0
- package/dist/commonjs/cwd-error.js +18 -0
- package/dist/commonjs/cwd-error.js.map +1 -0
- package/dist/commonjs/extract.d.ts +8 -0
- package/dist/commonjs/extract.d.ts.map +1 -0
- package/dist/commonjs/extract.js +141 -0
- package/dist/commonjs/extract.js.map +1 -0
- package/dist/commonjs/get-write-flag.d.ts +2 -0
- package/dist/commonjs/get-write-flag.d.ts.map +1 -0
- package/dist/commonjs/get-write-flag.js +29 -0
- package/dist/commonjs/get-write-flag.js.map +1 -0
- package/dist/commonjs/header.d.ts +54 -0
- package/dist/commonjs/header.d.ts.map +1 -0
- package/dist/commonjs/header.js +311 -0
- package/dist/commonjs/header.js.map +1 -0
- package/dist/commonjs/index.d.ts +19 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +54 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/large-numbers.d.ts +4 -0
- package/dist/commonjs/large-numbers.d.ts.map +1 -0
- package/dist/commonjs/large-numbers.js +99 -0
- package/dist/commonjs/large-numbers.js.map +1 -0
- package/dist/commonjs/list.d.ts +8 -0
- package/dist/commonjs/list.d.ts.map +1 -0
- package/dist/commonjs/list.js +167 -0
- package/dist/commonjs/list.js.map +1 -0
- package/dist/commonjs/mkdir.d.ts +27 -0
- package/dist/commonjs/mkdir.d.ts.map +1 -0
- package/dist/commonjs/mkdir.js +209 -0
- package/dist/commonjs/mkdir.js.map +1 -0
- package/dist/commonjs/mode-fix.d.ts +2 -0
- package/dist/commonjs/mode-fix.d.ts.map +1 -0
- package/dist/commonjs/mode-fix.js +29 -0
- package/dist/commonjs/mode-fix.js.map +1 -0
- package/dist/commonjs/normalize-unicode.d.ts +2 -0
- package/dist/commonjs/normalize-unicode.d.ts.map +1 -0
- package/dist/commonjs/normalize-unicode.js +17 -0
- package/dist/commonjs/normalize-unicode.js.map +1 -0
- package/dist/commonjs/normalize-windows-path.d.ts +2 -0
- package/dist/commonjs/normalize-windows-path.d.ts.map +1 -0
- package/dist/commonjs/normalize-windows-path.js +12 -0
- package/dist/commonjs/normalize-windows-path.js.map +1 -0
- package/dist/commonjs/options.d.ts +545 -0
- package/dist/commonjs/options.d.ts.map +1 -0
- package/dist/commonjs/options.js +55 -0
- package/dist/commonjs/options.js.map +1 -0
- package/dist/commonjs/pack.d.ts +98 -0
- package/dist/commonjs/pack.d.ts.map +1 -0
- package/dist/commonjs/pack.js +461 -0
- package/dist/commonjs/pack.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/parse.d.ts +84 -0
- package/dist/commonjs/parse.d.ts.map +1 -0
- package/dist/commonjs/parse.js +571 -0
- package/dist/commonjs/parse.js.map +1 -0
- package/dist/commonjs/path-reservations.d.ts +11 -0
- package/dist/commonjs/path-reservations.d.ts.map +1 -0
- package/dist/commonjs/path-reservations.js +169 -0
- package/dist/commonjs/path-reservations.js.map +1 -0
- package/dist/commonjs/pax.d.ts +27 -0
- package/dist/commonjs/pax.d.ts.map +1 -0
- package/dist/commonjs/pax.js +158 -0
- package/dist/commonjs/pax.js.map +1 -0
- package/dist/commonjs/read-entry.d.ts +37 -0
- package/dist/commonjs/read-entry.d.ts.map +1 -0
- package/dist/commonjs/read-entry.js +139 -0
- package/dist/commonjs/read-entry.js.map +1 -0
- package/dist/commonjs/replace.d.ts +5 -0
- package/dist/commonjs/replace.d.ts.map +1 -0
- package/dist/commonjs/replace.js +223 -0
- package/dist/commonjs/replace.js.map +1 -0
- package/dist/commonjs/strip-absolute-path.d.ts +2 -0
- package/dist/commonjs/strip-absolute-path.d.ts.map +1 -0
- package/dist/commonjs/strip-absolute-path.js +29 -0
- package/dist/commonjs/strip-absolute-path.js.map +1 -0
- package/dist/commonjs/strip-trailing-slashes.d.ts +2 -0
- package/dist/commonjs/strip-trailing-slashes.d.ts.map +1 -0
- package/dist/commonjs/strip-trailing-slashes.js +18 -0
- package/dist/commonjs/strip-trailing-slashes.js.map +1 -0
- package/dist/commonjs/symlink-error.d.ts +9 -0
- package/dist/commonjs/symlink-error.d.ts.map +1 -0
- package/dist/commonjs/symlink-error.js +19 -0
- package/dist/commonjs/symlink-error.js.map +1 -0
- package/dist/commonjs/types.d.ts +7 -0
- package/dist/commonjs/types.d.ts.map +1 -0
- package/dist/commonjs/types.js +50 -0
- package/dist/commonjs/types.js.map +1 -0
- package/dist/commonjs/unpack.d.ts +98 -0
- package/dist/commonjs/unpack.d.ts.map +1 -0
- package/dist/commonjs/unpack.js +921 -0
- package/dist/commonjs/unpack.js.map +1 -0
- package/dist/commonjs/update.d.ts +3 -0
- package/dist/commonjs/update.d.ts.map +1 -0
- package/dist/commonjs/update.js +47 -0
- package/dist/commonjs/update.js.map +1 -0
- package/dist/commonjs/warn-method.d.ts +20 -0
- package/dist/commonjs/warn-method.d.ts.map +1 -0
- package/dist/commonjs/warn-method.js +31 -0
- package/dist/commonjs/warn-method.js.map +1 -0
- package/dist/commonjs/winchars.d.ts +3 -0
- package/dist/commonjs/winchars.d.ts.map +1 -0
- package/dist/commonjs/winchars.js +14 -0
- package/dist/commonjs/winchars.js.map +1 -0
- package/dist/commonjs/write-entry.d.ts +125 -0
- package/dist/commonjs/write-entry.d.ts.map +1 -0
- package/dist/commonjs/write-entry.js +657 -0
- package/dist/commonjs/write-entry.js.map +1 -0
- package/dist/esm/create.d.ts +8 -0
- package/dist/esm/create.d.ts.map +1 -0
- package/dist/esm/create.js +99 -0
- package/dist/esm/create.js.map +1 -0
- package/dist/esm/cwd-error.d.ts +8 -0
- package/dist/esm/cwd-error.d.ts.map +1 -0
- package/dist/esm/cwd-error.js +14 -0
- package/dist/esm/cwd-error.js.map +1 -0
- package/dist/esm/extract.d.ts +8 -0
- package/dist/esm/extract.d.ts.map +1 -0
- package/dist/esm/extract.js +111 -0
- package/dist/esm/extract.js.map +1 -0
- package/dist/esm/get-write-flag.d.ts +2 -0
- package/dist/esm/get-write-flag.d.ts.map +1 -0
- package/dist/esm/get-write-flag.js +23 -0
- package/dist/esm/get-write-flag.js.map +1 -0
- package/dist/esm/header.d.ts +54 -0
- package/dist/esm/header.d.ts.map +1 -0
- package/dist/esm/header.js +284 -0
- package/dist/esm/header.js.map +1 -0
- package/dist/esm/index.d.ts +19 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +20 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/large-numbers.d.ts +4 -0
- package/dist/esm/large-numbers.d.ts.map +1 -0
- package/dist/esm/large-numbers.js +94 -0
- package/dist/esm/large-numbers.js.map +1 -0
- package/dist/esm/list.d.ts +8 -0
- package/dist/esm/list.d.ts.map +1 -0
- package/dist/esm/list.js +137 -0
- package/dist/esm/list.js.map +1 -0
- package/dist/esm/mkdir.d.ts +27 -0
- package/dist/esm/mkdir.d.ts.map +1 -0
- package/dist/esm/mkdir.js +201 -0
- package/dist/esm/mkdir.js.map +1 -0
- package/dist/esm/mode-fix.d.ts +2 -0
- package/dist/esm/mode-fix.d.ts.map +1 -0
- package/dist/esm/mode-fix.js +25 -0
- package/dist/esm/mode-fix.js.map +1 -0
- package/dist/esm/normalize-unicode.d.ts +2 -0
- package/dist/esm/normalize-unicode.d.ts.map +1 -0
- package/dist/esm/normalize-unicode.js +13 -0
- package/dist/esm/normalize-unicode.js.map +1 -0
- package/dist/esm/normalize-windows-path.d.ts +2 -0
- package/dist/esm/normalize-windows-path.d.ts.map +1 -0
- package/{lib → dist/esm}/normalize-windows-path.js +5 -4
- package/dist/esm/normalize-windows-path.js.map +1 -0
- package/dist/esm/options.d.ts +545 -0
- package/dist/esm/options.d.ts.map +1 -0
- package/dist/esm/options.js +48 -0
- package/dist/esm/options.js.map +1 -0
- package/dist/esm/pack.d.ts +98 -0
- package/dist/esm/pack.d.ts.map +1 -0
- package/dist/esm/pack.js +429 -0
- package/dist/esm/pack.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/parse.d.ts +84 -0
- package/dist/esm/parse.d.ts.map +1 -0
- package/dist/esm/parse.js +567 -0
- package/dist/esm/parse.js.map +1 -0
- package/dist/esm/path-reservations.d.ts +11 -0
- package/dist/esm/path-reservations.d.ts.map +1 -0
- package/dist/esm/path-reservations.js +165 -0
- package/dist/esm/path-reservations.js.map +1 -0
- package/dist/esm/pax.d.ts +27 -0
- package/dist/esm/pax.d.ts.map +1 -0
- package/dist/esm/pax.js +154 -0
- package/dist/esm/pax.js.map +1 -0
- package/dist/esm/read-entry.d.ts +37 -0
- package/dist/esm/read-entry.d.ts.map +1 -0
- package/dist/esm/read-entry.js +135 -0
- package/dist/esm/read-entry.js.map +1 -0
- package/dist/esm/replace.d.ts +5 -0
- package/dist/esm/replace.d.ts.map +1 -0
- package/dist/esm/replace.js +216 -0
- package/dist/esm/replace.js.map +1 -0
- package/dist/esm/strip-absolute-path.d.ts +2 -0
- package/dist/esm/strip-absolute-path.d.ts.map +1 -0
- package/dist/esm/strip-absolute-path.js +25 -0
- package/dist/esm/strip-absolute-path.js.map +1 -0
- package/dist/esm/strip-trailing-slashes.d.ts +2 -0
- package/dist/esm/strip-trailing-slashes.d.ts.map +1 -0
- package/dist/esm/strip-trailing-slashes.js +14 -0
- package/dist/esm/strip-trailing-slashes.js.map +1 -0
- package/dist/esm/symlink-error.d.ts +9 -0
- package/dist/esm/symlink-error.d.ts.map +1 -0
- package/dist/esm/symlink-error.js +15 -0
- package/dist/esm/symlink-error.js.map +1 -0
- package/dist/esm/types.d.ts +7 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +45 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/unpack.d.ts +98 -0
- package/dist/esm/unpack.d.ts.map +1 -0
- package/dist/esm/unpack.js +890 -0
- package/dist/esm/unpack.js.map +1 -0
- package/dist/esm/update.d.ts +3 -0
- package/dist/esm/update.d.ts.map +1 -0
- package/dist/esm/update.js +43 -0
- package/dist/esm/update.js.map +1 -0
- package/dist/esm/warn-method.d.ts +20 -0
- package/dist/esm/warn-method.d.ts.map +1 -0
- package/dist/esm/warn-method.js +27 -0
- package/dist/esm/warn-method.js.map +1 -0
- package/dist/esm/winchars.d.ts +3 -0
- package/dist/esm/winchars.d.ts.map +1 -0
- package/dist/esm/winchars.js +9 -0
- package/dist/esm/winchars.js.map +1 -0
- package/dist/esm/write-entry.d.ts +125 -0
- package/dist/esm/write-entry.d.ts.map +1 -0
- package/dist/esm/write-entry.js +625 -0
- package/dist/esm/write-entry.js.map +1 -0
- package/package.json +255 -40
- package/index.js +0 -18
- package/lib/create.js +0 -111
- package/lib/extract.js +0 -113
- package/lib/get-write-flag.js +0 -20
- package/lib/header.js +0 -304
- package/lib/high-level-opt.js +0 -29
- package/lib/large-numbers.js +0 -104
- package/lib/list.js +0 -139
- package/lib/mkdir.js +0 -229
- package/lib/mode-fix.js +0 -27
- package/lib/normalize-unicode.js +0 -12
- package/lib/pack.js +0 -432
- package/lib/parse.js +0 -552
- package/lib/path-reservations.js +0 -156
- package/lib/pax.js +0 -150
- package/lib/read-entry.js +0 -107
- package/lib/replace.js +0 -246
- package/lib/strip-absolute-path.js +0 -24
- package/lib/strip-trailing-slashes.js +0 -13
- package/lib/types.js +0 -44
- package/lib/unpack.js +0 -923
- package/lib/update.js +0 -40
- package/lib/warn-mixin.js +0 -24
- package/lib/winchars.js +0 -23
- package/lib/write-entry.js +0 -546
package/README.md
CHANGED
|
@@ -156,12 +156,13 @@ to see how tar is handling the issue.
|
|
|
156
156
|
The API mimics the `tar(1)` command line functionality, with aliases
|
|
157
157
|
for more human-readable option and function names. The goal is that
|
|
158
158
|
if you know how to use `tar(1)` in Unix, then you know how to use
|
|
159
|
-
`
|
|
159
|
+
`import('tar')` in JavaScript.
|
|
160
160
|
|
|
161
161
|
To replicate `tar czf my-tarball.tgz files and folders`, you'd do:
|
|
162
162
|
|
|
163
163
|
```js
|
|
164
|
-
tar
|
|
164
|
+
import { create } from 'tar'
|
|
165
|
+
create(
|
|
165
166
|
{
|
|
166
167
|
gzip: <true|gzip options>,
|
|
167
168
|
file: 'my-tarball.tgz'
|
|
@@ -173,9 +174,12 @@ tar.c(
|
|
|
173
174
|
To replicate `tar cz files and folders > my-tarball.tgz`, you'd do:
|
|
174
175
|
|
|
175
176
|
```js
|
|
176
|
-
tar
|
|
177
|
+
// if you're familiar with the tar(1) cli flags, this can be nice
|
|
178
|
+
import * as tar from 'tar'
|
|
179
|
+
tar.c(
|
|
177
180
|
{
|
|
178
|
-
|
|
181
|
+
// 'z' is alias for 'gzip' option
|
|
182
|
+
z: <true|gzip options>
|
|
179
183
|
},
|
|
180
184
|
['some', 'files', 'and', 'folders']
|
|
181
185
|
).pipe(fs.createWriteStream('my-tarball.tgz'))
|
|
@@ -184,9 +188,10 @@ tar.c( // or tar.create
|
|
|
184
188
|
To replicate `tar xf my-tarball.tgz` you'd do:
|
|
185
189
|
|
|
186
190
|
```js
|
|
187
|
-
tar.x(
|
|
191
|
+
tar.x( // or `tar.extract`
|
|
188
192
|
{
|
|
189
|
-
file
|
|
193
|
+
// or `file:`
|
|
194
|
+
f: 'my-tarball.tgz'
|
|
190
195
|
}
|
|
191
196
|
).then(_=> { .. tarball has been dumped in cwd .. })
|
|
192
197
|
```
|
|
@@ -424,11 +429,15 @@ The following options are supported:
|
|
|
424
429
|
that passes the filter.
|
|
425
430
|
- `onwarn` A function that will get called with `(code, message, data)` for
|
|
426
431
|
any warnings encountered. (See "Warnings and Errors")
|
|
427
|
-
- `
|
|
428
|
-
extracted file matches the entry mode. This
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
+
- `chmod` Set to true to call `fs.chmod()` to ensure that the
|
|
433
|
+
extracted file matches the entry mode. This may necessitate a
|
|
434
|
+
call to the deprecated and thread-unsafe `process.umask()`
|
|
435
|
+
method to determine the default umask value, unless a
|
|
436
|
+
`processUmask` options is also provided. Otherwise tar will
|
|
437
|
+
extract with whatever mode is provided, and let the process
|
|
438
|
+
`umask` apply normally.
|
|
439
|
+
- `processUmask` Set to an explicit numeric value to avoid
|
|
440
|
+
calling `process.umask()` when `chmod: true` is set.
|
|
432
441
|
- `maxDepth` The maximum depth of subfolders to extract into. This
|
|
433
442
|
defaults to 1024. Anything deeper than the limit will raise a
|
|
434
443
|
warning and skip the entry. Set to `Infinity` to remove the
|
|
@@ -630,6 +639,7 @@ The following options are supported:
|
|
|
630
639
|
default" for most unix systems, based on a `umask` value of `0o22`.
|
|
631
640
|
- `preservePaths` Allow absolute paths. By default, `/` is stripped
|
|
632
641
|
from absolute paths.
|
|
642
|
+
|
|
633
643
|
- `linkCache` A Map object containing the device and inode value for
|
|
634
644
|
any file whose nlink is > 1, to identify hard links.
|
|
635
645
|
- `statCache` A Map object that caches calls `lstat`.
|
|
@@ -750,11 +760,15 @@ Most unpack errors will cause a `warn` event to be emitted. If the
|
|
|
750
760
|
that passes the filter.
|
|
751
761
|
- `onwarn` A function that will get called with `(code, message, data)` for
|
|
752
762
|
any warnings encountered. (See "Warnings and Errors")
|
|
753
|
-
- `
|
|
754
|
-
extracted file matches the entry mode. This
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
763
|
+
- `chmod` Set to true to call `fs.chmod()` to ensure that the
|
|
764
|
+
extracted file matches the entry mode. This may necessitate a
|
|
765
|
+
call to the deprecated and thread-unsafe `process.umask()`
|
|
766
|
+
method to determine the default umask value, unless a
|
|
767
|
+
`processUmask` options is also provided. Otherwise tar will
|
|
768
|
+
extract with whatever mode is provided, and let the process
|
|
769
|
+
`umask` apply normally.
|
|
770
|
+
- `processUmask` Set to an explicit numeric value to avoid
|
|
771
|
+
calling `process.umask()` when `chmod: true` is set.
|
|
758
772
|
- `maxDepth` The maximum depth of subfolders to extract into. This
|
|
759
773
|
defaults to 1024. Anything deeper than the limit will raise a
|
|
760
774
|
warning and skip the entry. Set to `Infinity` to remove the
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TarOptionsWithAliases, TarOptionsWithAliasesFile, TarOptionsWithAliasesSync, TarOptionsWithAliasesSyncFile } from './options.js';
|
|
2
|
+
import { Pack } from './pack.js';
|
|
3
|
+
export declare function create(opt: TarOptionsWithAliasesSyncFile, files?: string[]): void;
|
|
4
|
+
export declare function create(opt: TarOptionsWithAliasesSync, files?: string[]): void;
|
|
5
|
+
export declare function create(opt: TarOptionsWithAliasesFile, files?: string[], cb?: () => any): Promise<void>;
|
|
6
|
+
export declare function create(opt: TarOptionsWithAliasesFile, cb: () => any): Promise<void>;
|
|
7
|
+
export declare function create(opt: TarOptionsWithAliases, files?: string[]): Pack;
|
|
8
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/create.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,cAAc,CAAA;AAMrB,OAAO,EAAE,IAAI,EAAY,MAAM,WAAW,CAAA;AAE1C,wBAAgB,MAAM,CACpB,GAAG,EAAE,6BAA6B,EAClC,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,IAAI,CAAA;AACP,wBAAgB,MAAM,CACpB,GAAG,EAAE,yBAAyB,EAC9B,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,IAAI,CAAA;AACP,wBAAgB,MAAM,CACpB,GAAG,EAAE,yBAAyB,EAC9B,KAAK,CAAC,EAAE,MAAM,EAAE,EAChB,EAAE,CAAC,EAAE,MAAM,GAAG,GACb,OAAO,CAAC,IAAI,CAAC,CAAA;AAChB,wBAAgB,MAAM,CACpB,GAAG,EAAE,yBAAyB,EAC9B,EAAE,EAAE,MAAM,GAAG,GACZ,OAAO,CAAC,IAAI,CAAC,CAAA;AAChB,wBAAgB,MAAM,CACpB,GAAG,EAAE,qBAAqB,EAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,IAAI,CAAA"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.create = void 0;
|
|
7
|
+
const options_js_1 = require("./options.js");
|
|
8
|
+
const fs_minipass_1 = require("@isaacs/fs-minipass");
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const list_js_1 = require("./list.js");
|
|
11
|
+
const pack_js_1 = require("./pack.js");
|
|
12
|
+
function create(opt_, files, cb) {
|
|
13
|
+
if (typeof files === 'function') {
|
|
14
|
+
cb = files;
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(opt_)) {
|
|
17
|
+
;
|
|
18
|
+
(files = opt_), (opt_ = {});
|
|
19
|
+
}
|
|
20
|
+
if (!files || !Array.isArray(files) || !files.length) {
|
|
21
|
+
throw new TypeError('no files or directories specified');
|
|
22
|
+
}
|
|
23
|
+
files = Array.from(files);
|
|
24
|
+
const opt = (0, options_js_1.dealias)(opt_);
|
|
25
|
+
if (opt.sync && typeof cb === 'function') {
|
|
26
|
+
throw new TypeError('callback not supported for sync tar functions');
|
|
27
|
+
}
|
|
28
|
+
if (!opt.file && typeof cb === 'function') {
|
|
29
|
+
throw new TypeError('callback only supported with file option');
|
|
30
|
+
}
|
|
31
|
+
return (0, options_js_1.isSyncFile)(opt)
|
|
32
|
+
? createFileSync(opt, files)
|
|
33
|
+
: (0, options_js_1.isFile)(opt)
|
|
34
|
+
? createFile(opt, files, cb)
|
|
35
|
+
: (0, options_js_1.isSync)(opt)
|
|
36
|
+
? createSync(opt, files)
|
|
37
|
+
: create_(opt, files);
|
|
38
|
+
}
|
|
39
|
+
exports.create = create;
|
|
40
|
+
const createFileSync = (opt, files) => {
|
|
41
|
+
const p = new pack_js_1.PackSync(opt);
|
|
42
|
+
const stream = new fs_minipass_1.WriteStreamSync(opt.file, {
|
|
43
|
+
mode: opt.mode || 0o666,
|
|
44
|
+
});
|
|
45
|
+
p.pipe(stream);
|
|
46
|
+
addFilesSync(p, files);
|
|
47
|
+
};
|
|
48
|
+
const createFile = (opt, files, cb) => {
|
|
49
|
+
const p = new pack_js_1.Pack(opt);
|
|
50
|
+
const stream = new fs_minipass_1.WriteStream(opt.file, {
|
|
51
|
+
mode: opt.mode || 0o666,
|
|
52
|
+
});
|
|
53
|
+
p.pipe(stream);
|
|
54
|
+
const promise = new Promise((res, rej) => {
|
|
55
|
+
stream.on('error', rej);
|
|
56
|
+
stream.on('close', res);
|
|
57
|
+
p.on('error', rej);
|
|
58
|
+
});
|
|
59
|
+
addFilesAsync(p, files);
|
|
60
|
+
return cb ? promise.then(cb, cb) : promise;
|
|
61
|
+
};
|
|
62
|
+
const addFilesSync = (p, files) => {
|
|
63
|
+
files.forEach(file => {
|
|
64
|
+
if (file.charAt(0) === '@') {
|
|
65
|
+
(0, list_js_1.list)({
|
|
66
|
+
file: node_path_1.default.resolve(p.cwd, file.slice(1)),
|
|
67
|
+
sync: true,
|
|
68
|
+
noResume: true,
|
|
69
|
+
onentry: entry => p.add(entry),
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
p.add(file);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
p.end();
|
|
77
|
+
};
|
|
78
|
+
const addFilesAsync = async (p, files) => {
|
|
79
|
+
for (let i = 0; i < files.length; i++) {
|
|
80
|
+
const file = String(files[i]);
|
|
81
|
+
if (file.charAt(0) === '@') {
|
|
82
|
+
await (0, list_js_1.list)({
|
|
83
|
+
file: node_path_1.default.resolve(String(p.cwd), file.slice(1)),
|
|
84
|
+
noResume: true,
|
|
85
|
+
onentry: entry => {
|
|
86
|
+
p.add(entry);
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
p.add(file);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
p.end();
|
|
95
|
+
};
|
|
96
|
+
const createSync = (opt, files) => {
|
|
97
|
+
const p = new pack_js_1.PackSync(opt);
|
|
98
|
+
addFilesSync(p, files);
|
|
99
|
+
return p;
|
|
100
|
+
};
|
|
101
|
+
const create_ = (opt, files) => {
|
|
102
|
+
const p = new pack_js_1.Pack(opt);
|
|
103
|
+
addFilesAsync(p, files);
|
|
104
|
+
return p;
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/create.ts"],"names":[],"mappings":";;;;;;AAAA,6CAaqB;AAErB,qDAAkE;AAElE,0DAA4B;AAC5B,uCAAgC;AAChC,uCAA0C;AAuB1C,SAAgB,MAAM,CACpB,IAA2B,EAC3B,KAA8B,EAC9B,EAAc;IAEd,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,EAAE,GAAG,KAAK,CAAA;IACZ,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,CAAC;QAAA,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAA;IAC9B,CAAC;IAED,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;QACrD,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAA;IAC1D,CAAC;IAED,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IA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":["import {\n dealias,\n isFile,\n isSync,\n isSyncFile,\n TarOptions,\n TarOptionsFile,\n TarOptionsSync,\n TarOptionsSyncFile,\n TarOptionsWithAliases,\n TarOptionsWithAliasesFile,\n TarOptionsWithAliasesSync,\n TarOptionsWithAliasesSyncFile,\n} from './options.js'\n\nimport { WriteStream, WriteStreamSync } from '@isaacs/fs-minipass'\nimport { Minipass } from 'minipass'\nimport path from 'node:path'\nimport { list } from './list.js'\nimport { Pack, PackSync } from './pack.js'\n\nexport function create(\n opt: TarOptionsWithAliasesSyncFile,\n files?: string[],\n): void\nexport function create(\n opt: TarOptionsWithAliasesSync,\n files?: string[],\n): void\nexport function create(\n opt: TarOptionsWithAliasesFile,\n files?: string[],\n cb?: () => any,\n): Promise<void>\nexport function create(\n opt: TarOptionsWithAliasesFile,\n cb: () => any,\n): Promise<void>\nexport function create(\n opt: TarOptionsWithAliases,\n files?: string[],\n): Pack\nexport function create(\n opt_: TarOptionsWithAliases,\n files?: string[] | (() => any),\n cb?: () => any,\n): void | Promise<void> | Pack {\n if (typeof files === 'function') {\n cb = files\n }\n\n if (Array.isArray(opt_)) {\n ;(files = opt_), (opt_ = {})\n }\n\n if (!files || !Array.isArray(files) || !files.length) {\n throw new TypeError('no files or directories specified')\n }\n\n files = Array.from(files)\n\n const opt = dealias(opt_)\n\n if (opt.sync && typeof cb === 'function') {\n throw new TypeError(\n 'callback not supported for sync tar functions',\n )\n }\n\n if (!opt.file && typeof cb === 'function') {\n throw new TypeError('callback only supported with file option')\n }\n\n return isSyncFile(opt)\n ? createFileSync(opt, files)\n : isFile(opt)\n ? createFile(opt, files, cb)\n : isSync(opt)\n ? createSync(opt, files)\n : create_(opt, files)\n}\n\nconst createFileSync = (opt: TarOptionsSyncFile, files: string[]) => {\n const p = new PackSync(opt)\n const stream = new WriteStreamSync(opt.file, {\n mode: opt.mode || 0o666,\n })\n p.pipe(stream as unknown as Minipass.Writable)\n addFilesSync(p, files)\n}\n\nconst createFile = (\n opt: TarOptionsFile,\n files: string[],\n cb?: () => any,\n) => {\n const p = new Pack(opt)\n const stream = new WriteStream(opt.file, {\n mode: opt.mode || 0o666,\n })\n p.pipe(stream as unknown as Minipass.Writable)\n\n const promise = new Promise<void>((res, rej) => {\n stream.on('error', rej)\n stream.on('close', res)\n p.on('error', rej)\n })\n\n addFilesAsync(p, files)\n\n return cb ? promise.then(cb, cb) : promise\n}\n\nconst addFilesSync = (p: PackSync, files: string[]) => {\n files.forEach(file => {\n if (file.charAt(0) === '@') {\n list({\n file: path.resolve(p.cwd, file.slice(1)),\n sync: true,\n noResume: true,\n onentry: entry => p.add(entry),\n })\n } else {\n p.add(file)\n }\n })\n p.end()\n}\n\nconst addFilesAsync = async (\n p: Pack,\n files: string[],\n): Promise<void> => {\n for (let i = 0; i < files.length; i++) {\n const file = String(files[i])\n if (file.charAt(0) === '@') {\n await list({\n file: path.resolve(String(p.cwd), file.slice(1)),\n noResume: true,\n onentry: entry => {\n p.add(entry)\n },\n })\n } else {\n p.add(file)\n }\n }\n p.end()\n}\n\nconst createSync = (opt: TarOptionsSync, files: string[]) => {\n const p = new PackSync(opt)\n addFilesSync(p, files)\n return p\n}\n\nconst create_ = (opt: TarOptions, files: string[]) => {\n const p = new Pack(opt)\n addFilesAsync(p, files)\n return p\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cwd-error.d.ts","sourceRoot":"","sources":["../../src/cwd-error.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAS,SAAQ,KAAK;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,OAAO,CAAU;gBAEd,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAMtC,IAAI,IAAI,WAEP;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CwdError = void 0;
|
|
4
|
+
class CwdError extends Error {
|
|
5
|
+
path;
|
|
6
|
+
code;
|
|
7
|
+
syscall = 'chdir';
|
|
8
|
+
constructor(path, code) {
|
|
9
|
+
super(`${code}: Cannot cd into '${path}'`);
|
|
10
|
+
this.path = path;
|
|
11
|
+
this.code = code;
|
|
12
|
+
}
|
|
13
|
+
get name() {
|
|
14
|
+
return 'CwdError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.CwdError = CwdError;
|
|
18
|
+
//# sourceMappingURL=cwd-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cwd-error.js","sourceRoot":"","sources":["../../src/cwd-error.ts"],"names":[],"mappings":";;;AAAA,MAAa,QAAS,SAAQ,KAAK;IACjC,IAAI,CAAQ;IACZ,IAAI,CAAQ;IACZ,OAAO,GAAY,OAAO,CAAA;IAE1B,YAAY,IAAY,EAAE,IAAY;QACpC,KAAK,CAAC,GAAG,IAAI,qBAAqB,IAAI,GAAG,CAAC,CAAA;QAC1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,UAAU,CAAA;IACnB,CAAC;CACF;AAdD,4BAcC","sourcesContent":["export class CwdError extends Error {\n path: string\n code: string\n syscall: 'chdir' = 'chdir'\n\n constructor(path: string, code: string) {\n super(`${code}: Cannot cd into '${path}'`)\n this.path = path\n this.code = code\n }\n\n get name() {\n return 'CwdError'\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TarOptionsWithAliases, TarOptionsWithAliasesFile, TarOptionsWithAliasesSync, TarOptionsWithAliasesSyncFile } from './options.js';
|
|
2
|
+
import { Unpack } from './unpack.js';
|
|
3
|
+
export declare function extract(opt: TarOptionsWithAliasesSyncFile, files?: string[]): void;
|
|
4
|
+
export declare function extract(opt: TarOptionsWithAliasesSync, files?: string[]): void;
|
|
5
|
+
export declare function extract(opt: TarOptionsWithAliasesFile, files?: string[], cb?: () => any): Promise<void>;
|
|
6
|
+
export declare function extract(opt: TarOptionsWithAliasesFile, cb: () => any): Promise<void>;
|
|
7
|
+
export declare function extract(opt: TarOptionsWithAliases, files?: string[]): Unpack;
|
|
8
|
+
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/extract.ts"],"names":[],"mappings":"AAIA,OAAO,EASL,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC9B,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,MAAM,EAAc,MAAM,aAAa,CAAA;AAEhD,wBAAgB,OAAO,CACrB,GAAG,EAAE,6BAA6B,EAClC,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,IAAI,CAAA;AACP,wBAAgB,OAAO,CACrB,GAAG,EAAE,yBAAyB,EAC9B,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,IAAI,CAAA;AACP,wBAAgB,OAAO,CACrB,GAAG,EAAE,yBAAyB,EAC9B,KAAK,CAAC,EAAE,MAAM,EAAE,EAChB,EAAE,CAAC,EAAE,MAAM,GAAG,GACb,OAAO,CAAC,IAAI,CAAC,CAAA;AAChB,wBAAgB,OAAO,CACrB,GAAG,EAAE,yBAAyB,EAC9B,EAAE,EAAE,MAAM,GAAG,GACZ,OAAO,CAAC,IAAI,CAAC,CAAA;AAChB,wBAAgB,OAAO,CACrB,GAAG,EAAE,qBAAqB,EAC1B,KAAK,CAAC,EAAE,MAAM,EAAE,GACf,MAAM,CAAA"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.extract = void 0;
|
|
30
|
+
// tar -x
|
|
31
|
+
const fsm = __importStar(require("@isaacs/fs-minipass"));
|
|
32
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
33
|
+
const node_path_1 = require("node:path");
|
|
34
|
+
const options_js_1 = require("./options.js");
|
|
35
|
+
const strip_trailing_slashes_js_1 = require("./strip-trailing-slashes.js");
|
|
36
|
+
const unpack_js_1 = require("./unpack.js");
|
|
37
|
+
function extract(opt_, files, cb) {
|
|
38
|
+
if (typeof opt_ === 'function') {
|
|
39
|
+
;
|
|
40
|
+
(cb = opt_), (files = undefined), (opt_ = {});
|
|
41
|
+
}
|
|
42
|
+
else if (Array.isArray(opt_)) {
|
|
43
|
+
;
|
|
44
|
+
(files = opt_), (opt_ = {});
|
|
45
|
+
}
|
|
46
|
+
if (typeof files === 'function') {
|
|
47
|
+
;
|
|
48
|
+
(cb = files), (files = undefined);
|
|
49
|
+
}
|
|
50
|
+
if (!files) {
|
|
51
|
+
files = [];
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
files = Array.from(files);
|
|
55
|
+
}
|
|
56
|
+
const opt = (0, options_js_1.dealias)(opt_);
|
|
57
|
+
if (opt.sync && typeof cb === 'function') {
|
|
58
|
+
throw new TypeError('callback not supported for sync tar functions');
|
|
59
|
+
}
|
|
60
|
+
if (!opt.file && typeof cb === 'function') {
|
|
61
|
+
throw new TypeError('callback only supported with file option');
|
|
62
|
+
}
|
|
63
|
+
if (files.length) {
|
|
64
|
+
filesFilter(opt, files);
|
|
65
|
+
}
|
|
66
|
+
return (0, options_js_1.isSyncFile)(opt)
|
|
67
|
+
? extractFileSync(opt)
|
|
68
|
+
: (0, options_js_1.isFile)(opt)
|
|
69
|
+
? extractFile(opt, cb)
|
|
70
|
+
: (0, options_js_1.isSync)(opt)
|
|
71
|
+
? extractSync(opt)
|
|
72
|
+
: extract_(opt);
|
|
73
|
+
}
|
|
74
|
+
exports.extract = extract;
|
|
75
|
+
// construct a filter that limits the file entries listed
|
|
76
|
+
// include child entries if a dir is included
|
|
77
|
+
const filesFilter = (opt, files) => {
|
|
78
|
+
const map = new Map(files.map(f => [(0, strip_trailing_slashes_js_1.stripTrailingSlashes)(f), true]));
|
|
79
|
+
const filter = opt.filter;
|
|
80
|
+
const mapHas = (file, r = '') => {
|
|
81
|
+
const root = r || (0, node_path_1.parse)(file).root || '.';
|
|
82
|
+
let ret;
|
|
83
|
+
if (file === root)
|
|
84
|
+
ret = false;
|
|
85
|
+
else {
|
|
86
|
+
const m = map.get(file);
|
|
87
|
+
if (m !== undefined) {
|
|
88
|
+
ret = m;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
ret = mapHas((0, node_path_1.dirname)(file), root);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
map.set(file, ret);
|
|
95
|
+
return ret;
|
|
96
|
+
};
|
|
97
|
+
opt.filter = filter
|
|
98
|
+
? (file, entry) => filter(file, entry) && mapHas((0, strip_trailing_slashes_js_1.stripTrailingSlashes)(file))
|
|
99
|
+
: file => mapHas((0, strip_trailing_slashes_js_1.stripTrailingSlashes)(file));
|
|
100
|
+
};
|
|
101
|
+
const extractFileSync = (opt) => {
|
|
102
|
+
const u = new unpack_js_1.UnpackSync(opt);
|
|
103
|
+
const file = opt.file;
|
|
104
|
+
const stat = node_fs_1.default.statSync(file);
|
|
105
|
+
// This trades a zero-byte read() syscall for a stat
|
|
106
|
+
// However, it will usually result in less memory allocation
|
|
107
|
+
const readSize = opt.maxReadSize || 16 * 1024 * 1024;
|
|
108
|
+
const stream = new fsm.ReadStreamSync(file, {
|
|
109
|
+
readSize: readSize,
|
|
110
|
+
size: stat.size,
|
|
111
|
+
});
|
|
112
|
+
stream.pipe(u);
|
|
113
|
+
};
|
|
114
|
+
const extractFile = (opt, cb) => {
|
|
115
|
+
const u = new unpack_js_1.Unpack(opt);
|
|
116
|
+
const readSize = opt.maxReadSize || 16 * 1024 * 1024;
|
|
117
|
+
const file = opt.file;
|
|
118
|
+
const p = new Promise((resolve, reject) => {
|
|
119
|
+
u.on('error', reject);
|
|
120
|
+
u.on('close', resolve);
|
|
121
|
+
// This trades a zero-byte read() syscall for a stat
|
|
122
|
+
// However, it will usually result in less memory allocation
|
|
123
|
+
node_fs_1.default.stat(file, (er, stat) => {
|
|
124
|
+
if (er) {
|
|
125
|
+
reject(er);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const stream = new fsm.ReadStream(file, {
|
|
129
|
+
readSize: readSize,
|
|
130
|
+
size: stat.size,
|
|
131
|
+
});
|
|
132
|
+
stream.on('error', reject);
|
|
133
|
+
stream.pipe(u);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
return cb ? p.then(cb, cb) : p;
|
|
138
|
+
};
|
|
139
|
+
const extractSync = (opt) => new unpack_js_1.UnpackSync(opt);
|
|
140
|
+
const extract_ = (opt) => new unpack_js_1.Unpack(opt);
|
|
141
|
+
//# sourceMappingURL=extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/extract.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS;AACT,yDAA0C;AAC1C,sDAAwB;AACxB,yCAA0C;AAC1C,6CAaqB;AACrB,2EAAkE;AAClE,2CAAgD;AAuBhD,SAAgB,OAAO,CACrB,IAA2B,EAC3B,KAA8B,EAC9B,EAAc;IAEd,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,CAAC;QAAA,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,KAAK,GAAG,SAAS,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAA;IAChD,CAAC;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,CAAC;QAAA,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,CAAA;IAC9B,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,CAAC;QAAA,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,KAAK,GAAG,SAAS,CAAC,CAAA;IACpC,CAAC;IAED,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,KAAK,GAAG,EAAE,CAAA;IACZ,CAAC;SAAM,CAAC;QACN,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;IAED,MAAM,GAAG,GAAG,IAAA,oBAAO,EAAC,IAAI,CAAC,CAAA;IAEzB,IAAI,GAAG,CAAC,IAAI,IA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AEhE,MAAM,QAAQ,GAAG,CAAC,GAAe,EAAE,EAAE,CAAC,IAAI,kBAAM,CAAC,GAAG,CAAC,CAAA","sourcesContent":["// tar -x\nimport * as fsm from '@isaacs/fs-minipass'\nimport fs from 'node:fs'\nimport { dirname, parse } from 'node:path'\nimport {\n dealias,\n isFile,\n isSync,\n isSyncFile,\n TarOptions,\n TarOptionsFile,\n TarOptionsSync,\n TarOptionsSyncFile,\n TarOptionsWithAliases,\n TarOptionsWithAliasesFile,\n TarOptionsWithAliasesSync,\n TarOptionsWithAliasesSyncFile,\n} from './options.js'\nimport { stripTrailingSlashes } from './strip-trailing-slashes.js'\nimport { Unpack, UnpackSync } from './unpack.js'\n\nexport function extract(\n opt: TarOptionsWithAliasesSyncFile,\n files?: string[],\n): void\nexport function extract(\n opt: TarOptionsWithAliasesSync,\n files?: string[],\n): void\nexport function extract(\n opt: TarOptionsWithAliasesFile,\n files?: string[],\n cb?: () => any,\n): Promise<void>\nexport function extract(\n opt: TarOptionsWithAliasesFile,\n cb: () => any,\n): Promise<void>\nexport function extract(\n opt: TarOptionsWithAliases,\n files?: string[],\n): Unpack\nexport function extract(\n opt_: TarOptionsWithAliases,\n files?: string[] | (() => any),\n cb?: () => any,\n): void | Promise<void> | Unpack {\n if (typeof opt_ === 'function') {\n ;(cb = opt_), (files = undefined), (opt_ = {})\n } else if (Array.isArray(opt_)) {\n ;(files = opt_), (opt_ = {})\n }\n\n if (typeof files === 'function') {\n ;(cb = files), (files = undefined)\n }\n\n if (!files) {\n files = []\n } else {\n files = Array.from(files)\n }\n\n const opt = dealias(opt_)\n\n if (opt.sync && typeof cb === 'function') {\n throw new TypeError(\n 'callback not supported for sync tar functions',\n )\n }\n\n if (!opt.file && typeof cb === 'function') {\n throw new TypeError('callback only supported with file option')\n }\n\n if (files.length) {\n filesFilter(opt, files)\n }\n\n return isSyncFile(opt)\n ? extractFileSync(opt)\n : isFile(opt)\n ? extractFile(opt, cb)\n : isSync(opt)\n ? extractSync(opt)\n : extract_(opt)\n}\n\n// construct a filter that limits the file entries listed\n// include child entries if a dir is included\nconst filesFilter = (opt: TarOptions, files: string[]) => {\n const map = new Map(files.map(f => [stripTrailingSlashes(f), true]))\n const filter = opt.filter\n\n const mapHas = (file: string, r: string = ''): boolean => {\n const root = r || parse(file).root || '.'\n let ret: boolean\n if (file === root) ret = false\n else {\n const m = map.get(file)\n if (m !== undefined) {\n ret = m\n } else {\n ret = mapHas(dirname(file), root)\n }\n }\n\n map.set(file, ret)\n return ret\n }\n\n opt.filter = filter\n ? (file, entry) =>\n filter(file, entry) && mapHas(stripTrailingSlashes(file))\n : file => mapHas(stripTrailingSlashes(file))\n}\n\nconst extractFileSync = (opt: TarOptionsSyncFile) => {\n const u = new UnpackSync(opt)\n\n const file = opt.file\n const stat = fs.statSync(file)\n // This trades a zero-byte read() syscall for a stat\n // However, it will usually result in less memory allocation\n const readSize = opt.maxReadSize || 16 * 1024 * 1024\n const stream = new fsm.ReadStreamSync(file, {\n readSize: readSize,\n size: stat.size,\n })\n stream.pipe(u)\n}\n\nconst extractFile = (\n opt: TarOptionsFile,\n cb?: () => void,\n) => {\n const u = new Unpack(opt)\n const readSize = opt.maxReadSize || 16 * 1024 * 1024\n\n const file = opt.file\n const p = new Promise<void>((resolve, reject) => {\n u.on('error', reject)\n u.on('close', resolve)\n\n // This trades a zero-byte read() syscall for a stat\n // However, it will usually result in less memory allocation\n fs.stat(file, (er, stat) => {\n if (er) {\n reject(er)\n } else {\n const stream = new fsm.ReadStream(file, {\n readSize: readSize,\n size: stat.size,\n })\n stream.on('error', reject)\n stream.pipe(u)\n }\n })\n })\n return cb ? p.then(cb, cb) : p\n}\n\nconst extractSync = (opt: TarOptionsSync) => new UnpackSync(opt)\n\nconst extract_ = (opt: TarOptions) => new Unpack(opt)\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-write-flag.d.ts","sourceRoot":"","sources":["../../src/get-write-flag.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,YAAY,2BAEd,MAAM,kBAAwC,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Get the appropriate flag to use for creating files
|
|
3
|
+
// We use fmap on Windows platforms for files less than
|
|
4
|
+
// 512kb. This is a fairly low limit, but avoids making
|
|
5
|
+
// things slower in some cases. Since most of what this
|
|
6
|
+
// library is used for is extracting tarballs of many
|
|
7
|
+
// relatively small files in npm packages and the like,
|
|
8
|
+
// it can be a big boost on Windows platforms.
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.getWriteFlag = void 0;
|
|
14
|
+
const fs_1 = __importDefault(require("fs"));
|
|
15
|
+
const platform = process.env.__FAKE_PLATFORM__ || process.platform;
|
|
16
|
+
const isWindows = platform === 'win32';
|
|
17
|
+
/* c8 ignore start */
|
|
18
|
+
const { O_CREAT, O_TRUNC, O_WRONLY } = fs_1.default.constants;
|
|
19
|
+
const UV_FS_O_FILEMAP = Number(process.env.__FAKE_FS_O_FILENAME__) ||
|
|
20
|
+
fs_1.default.constants.UV_FS_O_FILEMAP ||
|
|
21
|
+
0;
|
|
22
|
+
/* c8 ignore stop */
|
|
23
|
+
const fMapEnabled = isWindows && !!UV_FS_O_FILEMAP;
|
|
24
|
+
const fMapLimit = 512 * 1024;
|
|
25
|
+
const fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY;
|
|
26
|
+
exports.getWriteFlag = !fMapEnabled
|
|
27
|
+
? () => 'w'
|
|
28
|
+
: (size) => (size < fMapLimit ? fMapFlag : 'w');
|
|
29
|
+
//# sourceMappingURL=get-write-flag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-write-flag.js","sourceRoot":"","sources":["../../src/get-write-flag.ts"],"names":[],"mappings":";AAAA,qDAAqD;AACrD,uDAAuD;AACvD,wDAAwD;AACxD,wDAAwD;AACxD,qDAAqD;AACrD,uDAAuD;AACvD,8CAA8C;;;;;;AAE9C,4CAAmB;AAEnB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,OAAO,CAAC,QAAQ,CAAA;AAClE,MAAM,SAAS,GAAG,QAAQ,KAAK,OAAO,CAAA;AAEtC,qBAAqB;AACrB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,YAAE,CAAC,SAAS,CAAA;AACnD,MAAM,eAAe,GACnB,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;IAC1C,YAAE,CAAC,SAAS,CAAC,eAAe;IAC5B,CAAC,CAAA;AACH,oBAAoB;AAEpB,MAAM,WAAW,GAAG,SAAS,IAAI,CAAC,CAAC,eAAe,CAAA;AAClD,MAAM,SAAS,GAAG,GAAG,GAAG,IAAI,CAAA;AAC5B,MAAM,QAAQ,GAAG,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAA;AAClD,QAAA,YAAY,GAAG,CAAC,WAAW;IACtC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG;IACX,CAAC,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA","sourcesContent":["// Get the appropriate flag to use for creating files\n// We use fmap on Windows platforms for files less than\n// 512kb. This is a fairly low limit, but avoids making\n// things slower in some cases. Since most of what this\n// library is used for is extracting tarballs of many\n// relatively small files in npm packages and the like,\n// it can be a big boost on Windows platforms.\n\nimport fs from 'fs'\n\nconst platform = process.env.__FAKE_PLATFORM__ || process.platform\nconst isWindows = platform === 'win32'\n\n/* c8 ignore start */\nconst { O_CREAT, O_TRUNC, O_WRONLY } = fs.constants\nconst UV_FS_O_FILEMAP =\n Number(process.env.__FAKE_FS_O_FILENAME__) ||\n fs.constants.UV_FS_O_FILEMAP ||\n 0\n/* c8 ignore stop */\n\nconst fMapEnabled = isWindows && !!UV_FS_O_FILEMAP\nconst fMapLimit = 512 * 1024\nconst fMapFlag = UV_FS_O_FILEMAP | O_TRUNC | O_CREAT | O_WRONLY\nexport const getWriteFlag = !fMapEnabled\n ? () => 'w'\n : (size: number) => (size < fMapLimit ? fMapFlag : 'w')\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { EntryTypeCode, EntryTypeName } from './types.js';
|
|
3
|
+
export type HeaderData = {
|
|
4
|
+
path?: string;
|
|
5
|
+
mode?: number;
|
|
6
|
+
uid?: number;
|
|
7
|
+
gid?: number;
|
|
8
|
+
size?: number;
|
|
9
|
+
cksum?: number;
|
|
10
|
+
type?: EntryTypeName | 'Unsupported';
|
|
11
|
+
linkpath?: string;
|
|
12
|
+
uname?: string;
|
|
13
|
+
gname?: string;
|
|
14
|
+
devmaj?: number;
|
|
15
|
+
devmin?: number;
|
|
16
|
+
atime?: Date;
|
|
17
|
+
ctime?: Date;
|
|
18
|
+
mtime?: Date;
|
|
19
|
+
charset?: string;
|
|
20
|
+
comment?: string;
|
|
21
|
+
dev?: number;
|
|
22
|
+
ino?: number;
|
|
23
|
+
nlink?: number;
|
|
24
|
+
};
|
|
25
|
+
export declare class Header implements HeaderData {
|
|
26
|
+
#private;
|
|
27
|
+
cksumValid: boolean;
|
|
28
|
+
needPax: boolean;
|
|
29
|
+
nullBlock: boolean;
|
|
30
|
+
block?: Buffer;
|
|
31
|
+
path?: string;
|
|
32
|
+
mode?: number;
|
|
33
|
+
uid?: number;
|
|
34
|
+
gid?: number;
|
|
35
|
+
size?: number;
|
|
36
|
+
cksum?: number;
|
|
37
|
+
linkpath?: string;
|
|
38
|
+
uname?: string;
|
|
39
|
+
gname?: string;
|
|
40
|
+
devmaj: number;
|
|
41
|
+
devmin: number;
|
|
42
|
+
atime?: Date;
|
|
43
|
+
ctime?: Date;
|
|
44
|
+
mtime?: Date;
|
|
45
|
+
charset?: string;
|
|
46
|
+
comment?: string;
|
|
47
|
+
constructor(data?: Buffer | HeaderData, off?: number, ex?: HeaderData, gex?: HeaderData);
|
|
48
|
+
decode(buf: Buffer, off: number, ex?: HeaderData, gex?: HeaderData): void;
|
|
49
|
+
encode(buf?: Buffer, off?: number): boolean;
|
|
50
|
+
get type(): EntryTypeName;
|
|
51
|
+
get typeKey(): EntryTypeCode | 'Unsupported';
|
|
52
|
+
set type(type: EntryTypeCode | EntryTypeName | 'Unsupported');
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=header.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../src/header.ts"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAG9D,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,aAAa,GAAG,aAAa,CAAA;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,KAAK,CAAC,EAAE,IAAI,CAAA;IAIZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CA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