zip-lib 0.7.3 → 1.0.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.
- package/lib/cancelable.d.ts +38 -38
- package/lib/cancelable.js +65 -65
- package/lib/fs.js +175 -175
- package/lib/index.d.ts +25 -25
- package/lib/index.js +56 -56
- package/lib/unzip.d.ts +78 -78
- package/lib/unzip.js +358 -358
- package/lib/util.js +49 -49
- package/lib/zip.d.ts +59 -59
- package/lib/zip.js +213 -213
- package/package.json +8 -8
package/lib/index.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.extract = exports.archiveFolder = exports.archiveFile = void 0;
|
|
18
|
-
const zip_1 = require("./zip");
|
|
19
|
-
const unzip_1 = require("./unzip");
|
|
20
|
-
__exportStar(require("./zip"), exports);
|
|
21
|
-
__exportStar(require("./unzip"), exports);
|
|
22
|
-
/**
|
|
23
|
-
* Compress a single file to zip.
|
|
24
|
-
* @param file
|
|
25
|
-
* @param zipFile the zip file path.
|
|
26
|
-
* @param options
|
|
27
|
-
*/
|
|
28
|
-
function archiveFile(file, zipFile, options) {
|
|
29
|
-
const zip = new zip_1.Zip(options);
|
|
30
|
-
zip.addFile(file);
|
|
31
|
-
return zip.archive(zipFile);
|
|
32
|
-
}
|
|
33
|
-
exports.archiveFile = archiveFile;
|
|
34
|
-
/**
|
|
35
|
-
* Compress all the contents of the specified folder to zip.
|
|
36
|
-
* @param folder
|
|
37
|
-
* @param zipFile the zip file path.
|
|
38
|
-
* @param options
|
|
39
|
-
*/
|
|
40
|
-
function archiveFolder(folder, zipFile, options) {
|
|
41
|
-
const zip = new zip_1.Zip(options);
|
|
42
|
-
zip.addFolder(folder);
|
|
43
|
-
return zip.archive(zipFile);
|
|
44
|
-
}
|
|
45
|
-
exports.archiveFolder = archiveFolder;
|
|
46
|
-
/**
|
|
47
|
-
* Extract the zip file to the specified location.
|
|
48
|
-
* @param zipFile
|
|
49
|
-
* @param targetFolder
|
|
50
|
-
* @param options
|
|
51
|
-
*/
|
|
52
|
-
function extract(zipFile, targetFolder, options) {
|
|
53
|
-
const unzip = new unzip_1.Unzip(options);
|
|
54
|
-
return unzip.extract(zipFile, targetFolder);
|
|
55
|
-
}
|
|
56
|
-
exports.extract = extract;
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.extract = exports.archiveFolder = exports.archiveFile = void 0;
|
|
18
|
+
const zip_1 = require("./zip");
|
|
19
|
+
const unzip_1 = require("./unzip");
|
|
20
|
+
__exportStar(require("./zip"), exports);
|
|
21
|
+
__exportStar(require("./unzip"), exports);
|
|
22
|
+
/**
|
|
23
|
+
* Compress a single file to zip.
|
|
24
|
+
* @param file
|
|
25
|
+
* @param zipFile the zip file path.
|
|
26
|
+
* @param options
|
|
27
|
+
*/
|
|
28
|
+
function archiveFile(file, zipFile, options) {
|
|
29
|
+
const zip = new zip_1.Zip(options);
|
|
30
|
+
zip.addFile(file);
|
|
31
|
+
return zip.archive(zipFile);
|
|
32
|
+
}
|
|
33
|
+
exports.archiveFile = archiveFile;
|
|
34
|
+
/**
|
|
35
|
+
* Compress all the contents of the specified folder to zip.
|
|
36
|
+
* @param folder
|
|
37
|
+
* @param zipFile the zip file path.
|
|
38
|
+
* @param options
|
|
39
|
+
*/
|
|
40
|
+
function archiveFolder(folder, zipFile, options) {
|
|
41
|
+
const zip = new zip_1.Zip(options);
|
|
42
|
+
zip.addFolder(folder);
|
|
43
|
+
return zip.archive(zipFile);
|
|
44
|
+
}
|
|
45
|
+
exports.archiveFolder = archiveFolder;
|
|
46
|
+
/**
|
|
47
|
+
* Extract the zip file to the specified location.
|
|
48
|
+
* @param zipFile
|
|
49
|
+
* @param targetFolder
|
|
50
|
+
* @param options
|
|
51
|
+
*/
|
|
52
|
+
function extract(zipFile, targetFolder, options) {
|
|
53
|
+
const unzip = new unzip_1.Unzip(options);
|
|
54
|
+
return unzip.extract(zipFile, targetFolder);
|
|
55
|
+
}
|
|
56
|
+
exports.extract = extract;
|
package/lib/unzip.d.ts
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { Cancelable } from "./cancelable";
|
|
2
|
-
export interface IExtractOptions {
|
|
3
|
-
/**
|
|
4
|
-
* If it is `true`, the target directory will be deleted before extract.
|
|
5
|
-
* The default value is `false`.
|
|
6
|
-
*/
|
|
7
|
-
overwrite?: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* Extract symbolic links as files on Windows. This value is only available on Windows and ignored on other platforms.
|
|
10
|
-
* The default value is `true`.
|
|
11
|
-
*
|
|
12
|
-
* If `true`, the symlink in the zip will be extracted as a normal file on Windows.
|
|
13
|
-
*
|
|
14
|
-
* If `false`, the symlink in the zip will be extracted as a symlink correctly on Windows, but an `EPERM` error will be thrown under non-administrators.
|
|
15
|
-
*
|
|
16
|
-
* > ⚠**WARNING:** On Windows, the default security policy allows only administrators to create symbolic links.
|
|
17
|
-
* If you set `symlinkAsFileOnWindows` to `false` and the zip contains symlink,
|
|
18
|
-
* be sure to run the code under the administrator, otherwise an `EPERM` error will be thrown.
|
|
19
|
-
*/
|
|
20
|
-
symlinkAsFileOnWindows?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Called before an item is extracted.
|
|
23
|
-
* @param event
|
|
24
|
-
*/
|
|
25
|
-
onEntry?: (event: IEntryEvent) => void;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* The IEntryEvent interface represents an event that an entry is about to be extracted.
|
|
29
|
-
*/
|
|
30
|
-
export interface IEntryEvent {
|
|
31
|
-
/**
|
|
32
|
-
* Entry name.
|
|
33
|
-
*/
|
|
34
|
-
readonly entryName: string;
|
|
35
|
-
/**
|
|
36
|
-
* Total number of entries.
|
|
37
|
-
*/
|
|
38
|
-
readonly entryCount: number;
|
|
39
|
-
/**
|
|
40
|
-
* Prevent extracting current entry.
|
|
41
|
-
*/
|
|
42
|
-
preventDefault(): void;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Extract the zip file.
|
|
46
|
-
*/
|
|
47
|
-
export declare class Unzip extends Cancelable {
|
|
48
|
-
private options?;
|
|
49
|
-
/**
|
|
50
|
-
*
|
|
51
|
-
*/
|
|
52
|
-
constructor(options?: IExtractOptions | undefined);
|
|
53
|
-
private zipFile;
|
|
54
|
-
private token;
|
|
55
|
-
/**
|
|
56
|
-
* Extract the zip file to the specified location.
|
|
57
|
-
* @param zipFile
|
|
58
|
-
* @param targetFolder
|
|
59
|
-
* @param options
|
|
60
|
-
*/
|
|
61
|
-
extract(zipFile: string, targetFolder: string): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Cancel decompression.
|
|
64
|
-
* If the cancel method is called after the extract is complete, nothing will happen.
|
|
65
|
-
*/
|
|
66
|
-
cancel(): void;
|
|
67
|
-
private closeZip;
|
|
68
|
-
private openZip;
|
|
69
|
-
private handleEntry;
|
|
70
|
-
private openZipFileStream;
|
|
71
|
-
private extractEntry;
|
|
72
|
-
private writeEntryToFile;
|
|
73
|
-
private modeFromEntry;
|
|
74
|
-
private createSymlink;
|
|
75
|
-
private isOverwrite;
|
|
76
|
-
private onEntryCallback;
|
|
77
|
-
private symlinkToFile;
|
|
78
|
-
}
|
|
1
|
+
import { Cancelable } from "./cancelable";
|
|
2
|
+
export interface IExtractOptions {
|
|
3
|
+
/**
|
|
4
|
+
* If it is `true`, the target directory will be deleted before extract.
|
|
5
|
+
* The default value is `false`.
|
|
6
|
+
*/
|
|
7
|
+
overwrite?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Extract symbolic links as files on Windows. This value is only available on Windows and ignored on other platforms.
|
|
10
|
+
* The default value is `true`.
|
|
11
|
+
*
|
|
12
|
+
* If `true`, the symlink in the zip will be extracted as a normal file on Windows.
|
|
13
|
+
*
|
|
14
|
+
* If `false`, the symlink in the zip will be extracted as a symlink correctly on Windows, but an `EPERM` error will be thrown under non-administrators.
|
|
15
|
+
*
|
|
16
|
+
* > ⚠**WARNING:** On Windows, the default security policy allows only administrators to create symbolic links.
|
|
17
|
+
* If you set `symlinkAsFileOnWindows` to `false` and the zip contains symlink,
|
|
18
|
+
* be sure to run the code under the administrator, otherwise an `EPERM` error will be thrown.
|
|
19
|
+
*/
|
|
20
|
+
symlinkAsFileOnWindows?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Called before an item is extracted.
|
|
23
|
+
* @param event
|
|
24
|
+
*/
|
|
25
|
+
onEntry?: (event: IEntryEvent) => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The IEntryEvent interface represents an event that an entry is about to be extracted.
|
|
29
|
+
*/
|
|
30
|
+
export interface IEntryEvent {
|
|
31
|
+
/**
|
|
32
|
+
* Entry name.
|
|
33
|
+
*/
|
|
34
|
+
readonly entryName: string;
|
|
35
|
+
/**
|
|
36
|
+
* Total number of entries.
|
|
37
|
+
*/
|
|
38
|
+
readonly entryCount: number;
|
|
39
|
+
/**
|
|
40
|
+
* Prevent extracting current entry.
|
|
41
|
+
*/
|
|
42
|
+
preventDefault(): void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Extract the zip file.
|
|
46
|
+
*/
|
|
47
|
+
export declare class Unzip extends Cancelable {
|
|
48
|
+
private options?;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
*/
|
|
52
|
+
constructor(options?: IExtractOptions | undefined);
|
|
53
|
+
private zipFile;
|
|
54
|
+
private token;
|
|
55
|
+
/**
|
|
56
|
+
* Extract the zip file to the specified location.
|
|
57
|
+
* @param zipFile
|
|
58
|
+
* @param targetFolder
|
|
59
|
+
* @param options
|
|
60
|
+
*/
|
|
61
|
+
extract(zipFile: string, targetFolder: string): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Cancel decompression.
|
|
64
|
+
* If the cancel method is called after the extract is complete, nothing will happen.
|
|
65
|
+
*/
|
|
66
|
+
cancel(): void;
|
|
67
|
+
private closeZip;
|
|
68
|
+
private openZip;
|
|
69
|
+
private handleEntry;
|
|
70
|
+
private openZipFileStream;
|
|
71
|
+
private extractEntry;
|
|
72
|
+
private writeEntryToFile;
|
|
73
|
+
private modeFromEntry;
|
|
74
|
+
private createSymlink;
|
|
75
|
+
private isOverwrite;
|
|
76
|
+
private onEntryCallback;
|
|
77
|
+
private symlinkToFile;
|
|
78
|
+
}
|