soda-nodejs 0.1.5 → 0.2.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/README.md +23 -23
- package/dist/cjs/index.d.ts +0 -2
- package/dist/cjs/index.js +0 -4
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/utils/execAsync.d.ts +23 -9
- package/dist/cjs/utils/execAsync.js +21 -5
- package/dist/cjs/utils/execAsync.js.map +3 -3
- package/dist/cjs/utils/unzip.d.ts +5 -1
- package/dist/cjs/utils/unzip.js +2 -2
- package/dist/cjs/utils/unzip.js.map +2 -2
- package/dist/cjs/utils/zip.d.ts +5 -1
- package/dist/cjs/utils/zip.js +2 -2
- package/dist/cjs/utils/zip.js.map +2 -2
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.js +0 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/execAsync.d.ts +23 -9
- package/dist/esm/utils/execAsync.js +13 -8
- package/dist/esm/utils/execAsync.js.map +1 -1
- package/dist/esm/utils/unzip.d.ts +5 -1
- package/dist/esm/utils/unzip.js +5 -2
- package/dist/esm/utils/unzip.js.map +1 -1
- package/dist/esm/utils/zip.d.ts +5 -1
- package/dist/esm/utils/zip.js +5 -2
- package/dist/esm/utils/zip.js.map +1 -1
- package/package.json +2 -1
- package/src/index.ts +0 -2
- package/src/utils/execAsync.ts +23 -15
- package/src/utils/unzip.ts +6 -2
- package/src/utils/zip.ts +6 -2
- package/dist/cjs/utils/check7zip.d.ts +0 -4
- package/dist/cjs/utils/check7zip.js +0 -48
- package/dist/cjs/utils/check7zip.js.map +0 -7
- package/dist/cjs/utils/install7zip.d.ts +0 -4
- package/dist/cjs/utils/install7zip.js +0 -39
- package/dist/cjs/utils/install7zip.js.map +0 -7
- package/dist/esm/utils/check7zip.d.ts +0 -4
- package/dist/esm/utils/check7zip.js +0 -14
- package/dist/esm/utils/check7zip.js.map +0 -1
- package/dist/esm/utils/install7zip.d.ts +0 -4
- package/dist/esm/utils/install7zip.js +0 -14
- package/dist/esm/utils/install7zip.js.map +0 -1
- package/src/utils/check7zip.ts +0 -13
- package/src/utils/install7zip.ts +0 -13
package/README.md
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
# soda-node
|
|
2
|
-
|
|
3
|
-
[](https://npmjs.com/package/soda-node)
|
|
4
|
-
[](https://npmjs.com/package/soda-node)
|
|
5
|
-
|
|
6
|
-
## Install
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
$ pnpm install
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
$ npm run dev
|
|
14
|
-
$ npm run build
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Options
|
|
18
|
-
|
|
19
|
-
TODO
|
|
20
|
-
|
|
21
|
-
## LICENSE
|
|
22
|
-
|
|
23
|
-
MIT
|
|
1
|
+
# soda-node
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/soda-node)
|
|
4
|
+
[](https://npmjs.com/package/soda-node)
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
$ pnpm install
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
$ npm run dev
|
|
14
|
+
$ npm run build
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Options
|
|
18
|
+
|
|
19
|
+
TODO
|
|
20
|
+
|
|
21
|
+
## LICENSE
|
|
22
|
+
|
|
23
|
+
MIT
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -16,18 +16,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
// src/index.ts
|
|
17
17
|
var src_exports = {};
|
|
18
18
|
module.exports = __toCommonJS(src_exports);
|
|
19
|
-
__reExport(src_exports, require("./utils/check7zip"), module.exports);
|
|
20
19
|
__reExport(src_exports, require("./utils/execAsync"), module.exports);
|
|
21
|
-
__reExport(src_exports, require("./utils/install7zip"), module.exports);
|
|
22
20
|
__reExport(src_exports, require("./utils/saveFile"), module.exports);
|
|
23
21
|
__reExport(src_exports, require("./utils/spawnAsync"), module.exports);
|
|
24
22
|
__reExport(src_exports, require("./utils/unzip"), module.exports);
|
|
25
23
|
__reExport(src_exports, require("./utils/zip"), module.exports);
|
|
26
24
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27
25
|
0 && (module.exports = {
|
|
28
|
-
...require("./utils/check7zip"),
|
|
29
26
|
...require("./utils/execAsync"),
|
|
30
|
-
...require("./utils/install7zip"),
|
|
31
27
|
...require("./utils/saveFile"),
|
|
32
28
|
...require("./utils/spawnAsync"),
|
|
33
29
|
...require("./utils/unzip"),
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"@utils/
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,8BAAd;AACA,wBAAc,
|
|
4
|
+
"sourcesContent": ["export * from \"@utils/execAsync\"\nexport * from \"@utils/saveFile\"\nexport * from \"@utils/spawnAsync\"\nexport * from \"@utils/unzip\"\nexport * from \"@utils/zip\"\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,8BAAd;AACA,wBAAc,6BADd;AAEA,wBAAc,+BAFd;AAGA,wBAAc,0BAHd;AAIA,wBAAc,wBAJd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,19 +3,33 @@
|
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
import { ExecOptions } from "child_process";
|
|
5
5
|
import { ObjectEncodingOptions } from "fs";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import { Options } from "iconv-lite";
|
|
7
|
+
export type IconvDecodeOptions = {
|
|
8
|
+
encoding: string;
|
|
9
|
+
options?: Options;
|
|
9
10
|
};
|
|
10
|
-
export declare function execAsync(command: string): Promise<
|
|
11
|
+
export declare function execAsync(command: string): Promise<string>;
|
|
11
12
|
export declare function execAsync(command: string, options: {
|
|
12
13
|
encoding: "buffer" | null;
|
|
13
|
-
} & ExecOptions): Promise<
|
|
14
|
+
} & ExecOptions): Promise<Buffer>;
|
|
15
|
+
export declare function execAsync(command: string, options: {
|
|
16
|
+
encoding: "buffer" | null;
|
|
17
|
+
} & ExecOptions & {
|
|
18
|
+
decode: IconvDecodeOptions;
|
|
19
|
+
}): Promise<string>;
|
|
20
|
+
export declare function execAsync(command: string, options: {
|
|
21
|
+
encoding: BufferEncoding;
|
|
22
|
+
} & ExecOptions): Promise<string>;
|
|
14
23
|
export declare function execAsync(command: string, options: {
|
|
15
24
|
encoding: BufferEncoding;
|
|
16
|
-
} & ExecOptions): Promise<
|
|
25
|
+
} & ExecOptions): Promise<string | Buffer>;
|
|
17
26
|
export declare function execAsync(command: string, options: {
|
|
18
27
|
encoding: BufferEncoding;
|
|
19
|
-
} & ExecOptions
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
} & ExecOptions & {
|
|
29
|
+
decode: IconvDecodeOptions;
|
|
30
|
+
}): Promise<string>;
|
|
31
|
+
export declare function execAsync(command: string, options: ExecOptions): Promise<string>;
|
|
32
|
+
export declare function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions) | undefined | null): Promise<string | Buffer>;
|
|
33
|
+
export declare function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions & {
|
|
34
|
+
decode: IconvDecodeOptions;
|
|
35
|
+
}) | undefined | null): Promise<string>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/utils/execAsync.ts
|
|
@@ -23,14 +33,20 @@ __export(execAsync_exports, {
|
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(execAsync_exports);
|
|
25
35
|
var import_child_process = require("child_process");
|
|
36
|
+
var import_iconv_lite = __toESM(require("iconv-lite"));
|
|
26
37
|
async function execAsync(command, options) {
|
|
38
|
+
const decode = options?.decode;
|
|
39
|
+
if (typeof options === "object" && options !== null && options.decode) {
|
|
40
|
+
const { decode: decode2, ...rest } = options;
|
|
41
|
+
options = rest;
|
|
42
|
+
}
|
|
27
43
|
return await new Promise((resolve, reject) => {
|
|
28
44
|
(0, import_child_process.exec)(command, options, (error, stdout, stderr) => {
|
|
29
|
-
if (error)
|
|
30
|
-
reject(error);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
resolve(
|
|
45
|
+
if (error)
|
|
46
|
+
return reject(error);
|
|
47
|
+
if (decode && stdout instanceof Buffer)
|
|
48
|
+
return resolve(import_iconv_lite.default.decode(stdout, decode.encoding, decode.options));
|
|
49
|
+
resolve(stdout);
|
|
34
50
|
});
|
|
35
51
|
});
|
|
36
52
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/execAsync.ts"],
|
|
4
|
-
"sourcesContent": ["import { exec, ExecOptions } from \"child_process\"\r\nimport { ObjectEncodingOptions } from \"fs\"\r\n\r\nexport type
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": []
|
|
4
|
+
"sourcesContent": ["import { exec, ExecOptions } from \"child_process\"\r\nimport { ObjectEncodingOptions } from \"fs\"\r\nimport iconv, { Options } from \"iconv-lite\"\r\n\r\nexport type IconvDecodeOptions = {\r\n encoding: string\r\n options?: Options\r\n}\r\n\r\nexport async function execAsync(command: string): Promise<string>\r\nexport async function execAsync(command: string, options: { encoding: \"buffer\" | null } & ExecOptions): Promise<Buffer>\r\nexport async function execAsync(command: string, options: { encoding: \"buffer\" | null } & ExecOptions & { decode: IconvDecodeOptions }): Promise<string>\r\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<string>\r\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<string | Buffer>\r\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions & { decode: IconvDecodeOptions }): Promise<string>\r\nexport async function execAsync(command: string, options: ExecOptions): Promise<string>\r\nexport async function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions) | undefined | null): Promise<string | Buffer>\r\nexport async function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions & { decode: IconvDecodeOptions }) | undefined | null): Promise<string>\r\nexport async function execAsync(command: string, options?: any) {\r\n const decode = options?.decode as IconvDecodeOptions | undefined\r\n if (typeof options === \"object\" && options !== null && options.decode) {\r\n const { decode, ...rest } = options as { decode: IconvDecodeOptions }\r\n options = rest\r\n }\r\n return await new Promise<string | Buffer>((resolve, reject) => {\r\n exec(command, options, (error, stdout, stderr) => {\r\n if (error) return reject(error)\r\n // if (stderr) console.warn(stderr)\r\n if (decode && stdout instanceof Buffer) return resolve(iconv.decode(stdout, decode.encoding, decode.options))\r\n resolve(stdout)\r\n })\r\n })\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAkC;AAElC,wBAA+B;AAgB/B,eAAsB,UAAU,SAAiB,SAAe;AAC5D,QAAM,SAAS,SAAS;AACxB,MAAI,OAAO,YAAY,YAAY,YAAY,QAAQ,QAAQ,QAAQ;AACnE,UAAM,EAAE,QAAAA,SAAQ,GAAG,KAAK,IAAI;AAC5B,cAAU;AAAA,EACd;AACA,SAAO,MAAM,IAAI,QAAyB,CAAC,SAAS,WAAW;AAC3D,mCAAK,SAAS,SAAS,CAAC,OAAO,QAAQ,WAAW;AAC9C,UAAI;AAAO,eAAO,OAAO,KAAK;AAE9B,UAAI,UAAU,kBAAkB;AAAQ,eAAO,QAAQ,kBAAAC,QAAM,OAAO,QAAQ,OAAO,UAAU,OAAO,OAAO,CAAC;AAC5G,cAAQ,MAAM;AAAA,IAClB,CAAC;AAAA,EACL,CAAC;AACL;",
|
|
6
|
+
"names": ["decode", "iconv"]
|
|
7
7
|
}
|
|
@@ -7,6 +7,10 @@ export type UnzipOptions = {
|
|
|
7
7
|
* 解压到的目标文件夹位置
|
|
8
8
|
*/
|
|
9
9
|
output: string;
|
|
10
|
+
/**
|
|
11
|
+
* 压缩文件时的工作目录
|
|
12
|
+
*/
|
|
13
|
+
cwd?: string;
|
|
10
14
|
};
|
|
11
15
|
/**
|
|
12
16
|
* 使用 7z 命令解压文件
|
|
@@ -19,4 +23,4 @@ export type UnzipOptions = {
|
|
|
19
23
|
* 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功
|
|
20
24
|
* 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确
|
|
21
25
|
*/
|
|
22
|
-
export declare function unzip({ input, output }: UnzipOptions): Promise<
|
|
26
|
+
export declare function unzip({ input, output, cwd }: UnzipOptions): Promise<string>;
|
package/dist/cjs/utils/unzip.js
CHANGED
|
@@ -34,9 +34,9 @@ __export(unzip_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(unzip_exports);
|
|
35
35
|
var import_which = __toESM(require("which"));
|
|
36
36
|
var import_execAsync = require("./execAsync");
|
|
37
|
-
async function unzip({ input, output }) {
|
|
37
|
+
async function unzip({ input, output, cwd }) {
|
|
38
38
|
await (0, import_which.default)("7z");
|
|
39
|
-
return await (0, import_execAsync.execAsync)(`7z x ${input} -o${output}
|
|
39
|
+
return await (0, import_execAsync.execAsync)(`7z x ${input} -o${output}`, { cwd });
|
|
40
40
|
}
|
|
41
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
42
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/unzip.ts"],
|
|
4
|
-
"sourcesContent": ["import which from \"which\"\r\nimport { execAsync } from \"./execAsync\"\r\n\r\nexport type UnzipOptions = {\r\n /**\r\n * 要解压的文件\r\n */\r\n input: string\r\n /**\r\n * 解压到的目标文件夹位置\r\n */\r\n output: string\r\n}\r\n\r\n/**\r\n * 使用 7z 命令解压文件\r\n * - 如果没有安装 7z,请先安装 7z 后再执行\r\n * - 下载地址:https://www.7-zip.org/download.html\r\n * - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中\r\n * 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\r\n * 2. 在系统变量中找到并选中 Path,点击编辑\r\n * 3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定\r\n * 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\r\n * 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\r\n */\r\nexport async function unzip({ input, output }: UnzipOptions) {\r\n await which(\"7z\")\r\n return await execAsync(`7z x ${input} -o${output}
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,uBAA0B;
|
|
4
|
+
"sourcesContent": ["import which from \"which\"\r\nimport { execAsync } from \"./execAsync\"\r\n\r\nexport type UnzipOptions = {\r\n /**\r\n * 要解压的文件\r\n */\r\n input: string\r\n /**\r\n * 解压到的目标文件夹位置\r\n */\r\n output: string\r\n /**\r\n * 压缩文件时的工作目录\r\n */\r\n cwd?: string\r\n}\r\n\r\n/**\r\n * 使用 7z 命令解压文件\r\n * - 如果没有安装 7z,请先安装 7z 后再执行\r\n * - 下载地址:https://www.7-zip.org/download.html\r\n * - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中\r\n * 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\r\n * 2. 在系统变量中找到并选中 Path,点击编辑\r\n * 3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定\r\n * 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\r\n * 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\r\n */\r\nexport async function unzip({ input, output, cwd }: UnzipOptions) {\r\n await which(\"7z\")\r\n return await execAsync(`7z x ${input} -o${output}`, { cwd })\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAClB,uBAA0B;AA4B1B,eAAsB,MAAM,EAAE,OAAO,QAAQ,IAAI,GAAiB;AAC9D,YAAM,aAAAA,SAAM,IAAI;AAChB,SAAO,UAAM,4BAAU,QAAQ,WAAW,UAAU,EAAE,IAAI,CAAC;AAC/D;",
|
|
6
6
|
"names": ["which"]
|
|
7
7
|
}
|
package/dist/cjs/utils/zip.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ export type ZipOptions = {
|
|
|
19
19
|
* 是否加密
|
|
20
20
|
*/
|
|
21
21
|
password?: string;
|
|
22
|
+
/**
|
|
23
|
+
* 压缩文件时的工作目录
|
|
24
|
+
*/
|
|
25
|
+
cwd?: string;
|
|
22
26
|
};
|
|
23
27
|
/**
|
|
24
28
|
* 使用 7z 命令压缩文件
|
|
@@ -31,4 +35,4 @@ export type ZipOptions = {
|
|
|
31
35
|
* 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功
|
|
32
36
|
* 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确
|
|
33
37
|
*/
|
|
34
|
-
export declare function zip({ input, output, thread, level, password }: ZipOptions): Promise<
|
|
38
|
+
export declare function zip({ input, output, thread, level, password, cwd }: ZipOptions): Promise<string>;
|
package/dist/cjs/utils/zip.js
CHANGED
|
@@ -35,12 +35,12 @@ module.exports = __toCommonJS(zip_exports);
|
|
|
35
35
|
var import_os = require("os");
|
|
36
36
|
var import_which = __toESM(require("which"));
|
|
37
37
|
var import_execAsync = require("./execAsync");
|
|
38
|
-
async function zip({ input, output, thread = "auto", level, password }) {
|
|
38
|
+
async function zip({ input, output, thread = "auto", level, password, cwd }) {
|
|
39
39
|
await (0, import_which.default)("7z");
|
|
40
40
|
input = Array.isArray(input) ? input.join(" ") : input;
|
|
41
41
|
if (thread === "max")
|
|
42
42
|
thread = (0, import_os.cpus)().length;
|
|
43
|
-
return await (0, import_execAsync.execAsync)(`7z a ${output} ${input} -mmt=${thread === "auto" ? "on" : thread}${typeof level === "number" ? ` -mx=${level}` : ""}${password ? ` -p${password}` : ""}
|
|
43
|
+
return await (0, import_execAsync.execAsync)(`7z a ${output} ${input} -mmt=${thread === "auto" ? "on" : thread}${typeof level === "number" ? ` -mx=${level}` : ""}${password ? ` -p${password}` : ""}`, { cwd });
|
|
44
44
|
}
|
|
45
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
46
|
0 && (module.exports = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/zip.ts"],
|
|
4
|
-
"sourcesContent": ["import { cpus } from \"os\"\r\nimport which from \"which\"\r\nimport { execAsync } from \"./execAsync\"\r\n\r\nexport type ZipOptions = {\r\n /**\r\n * 要压缩的文件\r\n */\r\n input: string | string[]\r\n /**\r\n * 压缩到的目标位置,文件名的后缀就是压缩格式,例如:.zip、.7z\r\n */\r\n output: string\r\n /**\r\n * 线程数\r\n */\r\n thread?: number | \"auto\" | \"max\"\r\n /**\r\n * 压缩等级,0-9\r\n */\r\n level?: number\r\n /**\r\n * 是否加密\r\n */\r\n password?: string\r\n}\r\n\r\n/**\r\n * 使用 7z 命令压缩文件\r\n * - 如果没有安装 7z,请先安装 7z 后再执行\r\n * - 下载地址:https://www.7-zip.org/download.html\r\n * - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中\r\n * 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\r\n * 2. 在系统变量中找到并选中 Path,点击编辑\r\n * 3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定\r\n * 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\r\n * 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\r\n */\r\nexport async function zip({ input, output, thread = \"auto\", level, password }: ZipOptions) {\r\n await which(\"7z\")\r\n input = Array.isArray(input) ? input.join(\" \") : input\r\n if (thread === \"max\") thread = cpus().length\r\n return await execAsync(`7z a ${output} ${input} -mmt=${thread === \"auto\" ? \"on\" : thread}${typeof level === \"number\" ? ` -mx=${level}` : \"\"}${password ? ` -p${password}` : \"\"}
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqB;AACrB,mBAAkB;AAClB,uBAA0B;
|
|
4
|
+
"sourcesContent": ["import { cpus } from \"os\"\r\nimport which from \"which\"\r\nimport { execAsync } from \"./execAsync\"\r\n\r\nexport type ZipOptions = {\r\n /**\r\n * 要压缩的文件\r\n */\r\n input: string | string[]\r\n /**\r\n * 压缩到的目标位置,文件名的后缀就是压缩格式,例如:.zip、.7z\r\n */\r\n output: string\r\n /**\r\n * 线程数\r\n */\r\n thread?: number | \"auto\" | \"max\"\r\n /**\r\n * 压缩等级,0-9\r\n */\r\n level?: number\r\n /**\r\n * 是否加密\r\n */\r\n password?: string\r\n /**\r\n * 压缩文件时的工作目录\r\n */\r\n cwd?: string\r\n}\r\n\r\n/**\r\n * 使用 7z 命令压缩文件\r\n * - 如果没有安装 7z,请先安装 7z 后再执行\r\n * - 下载地址:https://www.7-zip.org/download.html\r\n * - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中\r\n * 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\r\n * 2. 在系统变量中找到并选中 Path,点击编辑\r\n * 3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定\r\n * 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\r\n * 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\r\n */\r\nexport async function zip({ input, output, thread = \"auto\", level, password, cwd }: ZipOptions) {\r\n await which(\"7z\")\r\n input = Array.isArray(input) ? input.join(\" \") : input\r\n if (thread === \"max\") thread = cpus().length\r\n return await execAsync(`7z a ${output} ${input} -mmt=${thread === \"auto\" ? \"on\" : thread}${typeof level === \"number\" ? ` -mx=${level}` : \"\"}${password ? ` -p${password}` : \"\"}`, { cwd })\r\n}\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqB;AACrB,mBAAkB;AAClB,uBAA0B;AAwC1B,eAAsB,IAAI,EAAE,OAAO,QAAQ,SAAS,QAAQ,OAAO,UAAU,IAAI,GAAe;AAC5F,YAAM,aAAAA,SAAM,IAAI;AAChB,UAAQ,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAK,GAAG,IAAI;AACjD,MAAI,WAAW;AAAO,iBAAS,gBAAK,EAAE;AACtC,SAAO,UAAM,4BAAU,QAAQ,UAAU,cAAc,WAAW,SAAS,OAAO,SAAS,OAAO,UAAU,WAAW,QAAQ,UAAU,KAAK,WAAW,MAAM,aAAa,MAAM,EAAE,IAAI,CAAC;AAC7L;",
|
|
6
6
|
"names": ["which"]
|
|
7
7
|
}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"@utils/
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"@utils/execAsync\"\nexport * from \"@utils/saveFile\"\nexport * from \"@utils/spawnAsync\"\nexport * from \"@utils/unzip\"\nexport * from \"@utils/zip\"\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA"}
|
|
@@ -3,19 +3,33 @@
|
|
|
3
3
|
/// <reference types="node" />
|
|
4
4
|
import { ExecOptions } from "child_process";
|
|
5
5
|
import { ObjectEncodingOptions } from "fs";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import { Options } from "iconv-lite";
|
|
7
|
+
export type IconvDecodeOptions = {
|
|
8
|
+
encoding: string;
|
|
9
|
+
options?: Options;
|
|
9
10
|
};
|
|
10
|
-
export declare function execAsync(command: string): Promise<
|
|
11
|
+
export declare function execAsync(command: string): Promise<string>;
|
|
11
12
|
export declare function execAsync(command: string, options: {
|
|
12
13
|
encoding: "buffer" | null;
|
|
13
|
-
} & ExecOptions): Promise<
|
|
14
|
+
} & ExecOptions): Promise<Buffer>;
|
|
15
|
+
export declare function execAsync(command: string, options: {
|
|
16
|
+
encoding: "buffer" | null;
|
|
17
|
+
} & ExecOptions & {
|
|
18
|
+
decode: IconvDecodeOptions;
|
|
19
|
+
}): Promise<string>;
|
|
20
|
+
export declare function execAsync(command: string, options: {
|
|
21
|
+
encoding: BufferEncoding;
|
|
22
|
+
} & ExecOptions): Promise<string>;
|
|
14
23
|
export declare function execAsync(command: string, options: {
|
|
15
24
|
encoding: BufferEncoding;
|
|
16
|
-
} & ExecOptions): Promise<
|
|
25
|
+
} & ExecOptions): Promise<string | Buffer>;
|
|
17
26
|
export declare function execAsync(command: string, options: {
|
|
18
27
|
encoding: BufferEncoding;
|
|
19
|
-
} & ExecOptions
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
} & ExecOptions & {
|
|
29
|
+
decode: IconvDecodeOptions;
|
|
30
|
+
}): Promise<string>;
|
|
31
|
+
export declare function execAsync(command: string, options: ExecOptions): Promise<string>;
|
|
32
|
+
export declare function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions) | undefined | null): Promise<string | Buffer>;
|
|
33
|
+
export declare function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions & {
|
|
34
|
+
decode: IconvDecodeOptions;
|
|
35
|
+
}) | undefined | null): Promise<string>;
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { exec } from "child_process";
|
|
2
|
+
import iconv from "iconv-lite";
|
|
2
3
|
export async function execAsync(command, options) {
|
|
4
|
+
const decode = options?.decode;
|
|
5
|
+
if (typeof options === "object" && options !== null && options.decode) {
|
|
6
|
+
const {
|
|
7
|
+
decode,
|
|
8
|
+
...rest
|
|
9
|
+
} = options;
|
|
10
|
+
options = rest;
|
|
11
|
+
}
|
|
3
12
|
return await new Promise((resolve, reject) => {
|
|
4
13
|
exec(command, options, (error, stdout, stderr) => {
|
|
5
|
-
if (error)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
resolve({
|
|
10
|
-
stdout,
|
|
11
|
-
stderr
|
|
12
|
-
});
|
|
14
|
+
if (error) return reject(error);
|
|
15
|
+
// if (stderr) console.warn(stderr)
|
|
16
|
+
if (decode && stdout instanceof Buffer) return resolve(iconv.decode(stdout, decode.encoding, decode.options));
|
|
17
|
+
resolve(stdout);
|
|
13
18
|
});
|
|
14
19
|
});
|
|
15
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["exec","execAsync","command","options","Promise","resolve","reject","error","stdout","stderr"],"sources":["../../../src/utils/execAsync.ts"],"sourcesContent":["import { exec, ExecOptions } from \"child_process\"\r\nimport { ObjectEncodingOptions } from \"fs\"\r\n\r\nexport type
|
|
1
|
+
{"version":3,"names":["exec","iconv","execAsync","command","options","decode","rest","Promise","resolve","reject","error","stdout","stderr","Buffer","encoding"],"sources":["../../../src/utils/execAsync.ts"],"sourcesContent":["import { exec, ExecOptions } from \"child_process\"\r\nimport { ObjectEncodingOptions } from \"fs\"\r\nimport iconv, { Options } from \"iconv-lite\"\r\n\r\nexport type IconvDecodeOptions = {\r\n encoding: string\r\n options?: Options\r\n}\r\n\r\nexport async function execAsync(command: string): Promise<string>\r\nexport async function execAsync(command: string, options: { encoding: \"buffer\" | null } & ExecOptions): Promise<Buffer>\r\nexport async function execAsync(command: string, options: { encoding: \"buffer\" | null } & ExecOptions & { decode: IconvDecodeOptions }): Promise<string>\r\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<string>\r\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<string | Buffer>\r\nexport async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions & { decode: IconvDecodeOptions }): Promise<string>\r\nexport async function execAsync(command: string, options: ExecOptions): Promise<string>\r\nexport async function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions) | undefined | null): Promise<string | Buffer>\r\nexport async function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions & { decode: IconvDecodeOptions }) | undefined | null): Promise<string>\r\nexport async function execAsync(command: string, options?: any) {\r\n const decode = options?.decode as IconvDecodeOptions | undefined\r\n if (typeof options === \"object\" && options !== null && options.decode) {\r\n const { decode, ...rest } = options as { decode: IconvDecodeOptions }\r\n options = rest\r\n }\r\n return await new Promise<string | Buffer>((resolve, reject) => {\r\n exec(command, options, (error, stdout, stderr) => {\r\n if (error) return reject(error)\r\n // if (stderr) console.warn(stderr)\r\n if (decode && stdout instanceof Buffer) return resolve(iconv.decode(stdout, decode.encoding, decode.options))\r\n resolve(stdout)\r\n })\r\n })\r\n}\r\n"],"mappings":"AAAA,SAASA,IAAI,QAAqB,eAAe;AAEjD,OAAOC,KAAK,MAAmB,YAAY;AAgB3C,OAAO,eAAeC,SAASA,CAACC,OAAe,EAAEC,OAAa,EAAE;EAC5D,MAAMC,MAAM,GAAGD,OAAO,EAAEC,MAAwC;EAChE,IAAI,OAAOD,OAAO,KAAK,QAAQ,IAAIA,OAAO,KAAK,IAAI,IAAIA,OAAO,CAACC,MAAM,EAAE;IACnE,MAAM;MAAEA,MAAM;MAAE,GAAGC;IAAK,CAAC,GAAGF,OAAyC;IACrEA,OAAO,GAAGE,IAAI;EAClB;EACA,OAAO,MAAM,IAAIC,OAAO,CAAkB,CAACC,OAAO,EAAEC,MAAM,KAAK;IAC3DT,IAAI,CAACG,OAAO,EAAEC,OAAO,EAAE,CAACM,KAAK,EAAEC,MAAM,EAAEC,MAAM,KAAK;MAC9C,IAAIF,KAAK,EAAE,OAAOD,MAAM,CAACC,KAAK,CAAC;MAC/B;MACA,IAAIL,MAAM,IAAIM,MAAM,YAAYE,MAAM,EAAE,OAAOL,OAAO,CAACP,KAAK,CAACI,MAAM,CAACM,MAAM,EAAEN,MAAM,CAACS,QAAQ,EAAET,MAAM,CAACD,OAAO,CAAC,CAAC;MAC7GI,OAAO,CAACG,MAAM,CAAC;IACnB,CAAC,CAAC;EACN,CAAC,CAAC;AACN"}
|
|
@@ -7,6 +7,10 @@ export type UnzipOptions = {
|
|
|
7
7
|
* 解压到的目标文件夹位置
|
|
8
8
|
*/
|
|
9
9
|
output: string;
|
|
10
|
+
/**
|
|
11
|
+
* 压缩文件时的工作目录
|
|
12
|
+
*/
|
|
13
|
+
cwd?: string;
|
|
10
14
|
};
|
|
11
15
|
/**
|
|
12
16
|
* 使用 7z 命令解压文件
|
|
@@ -19,4 +23,4 @@ export type UnzipOptions = {
|
|
|
19
23
|
* 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功
|
|
20
24
|
* 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确
|
|
21
25
|
*/
|
|
22
|
-
export declare function unzip({ input, output }: UnzipOptions): Promise<
|
|
26
|
+
export declare function unzip({ input, output, cwd }: UnzipOptions): Promise<string>;
|
package/dist/esm/utils/unzip.js
CHANGED
|
@@ -13,9 +13,12 @@ import { execAsync } from "./execAsync";
|
|
|
13
13
|
*/
|
|
14
14
|
export async function unzip({
|
|
15
15
|
input,
|
|
16
|
-
output
|
|
16
|
+
output,
|
|
17
|
+
cwd
|
|
17
18
|
}) {
|
|
18
19
|
await which("7z");
|
|
19
|
-
return await execAsync(`7z x ${input} -o${output}
|
|
20
|
+
return await execAsync(`7z x ${input} -o${output}`, {
|
|
21
|
+
cwd
|
|
22
|
+
});
|
|
20
23
|
}
|
|
21
24
|
//# sourceMappingURL=unzip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["which","execAsync","unzip","input","output"],"sources":["../../../src/utils/unzip.ts"],"sourcesContent":["import which from \"which\"\r\nimport { execAsync } from \"./execAsync\"\r\n\r\nexport type UnzipOptions = {\r\n /**\r\n * 要解压的文件\r\n */\r\n input: string\r\n /**\r\n * 解压到的目标文件夹位置\r\n */\r\n output: string\r\n}\r\n\r\n/**\r\n * 使用 7z 命令解压文件\r\n * - 如果没有安装 7z,请先安装 7z 后再执行\r\n * - 下载地址:https://www.7-zip.org/download.html\r\n * - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中\r\n * 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\r\n * 2. 在系统变量中找到并选中 Path,点击编辑\r\n * 3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定\r\n * 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\r\n * 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\r\n */\r\nexport async function unzip({ input, output }: UnzipOptions) {\r\n await which(\"7z\")\r\n return await execAsync(`7z x ${input} -o${output}
|
|
1
|
+
{"version":3,"names":["which","execAsync","unzip","input","output","cwd"],"sources":["../../../src/utils/unzip.ts"],"sourcesContent":["import which from \"which\"\r\nimport { execAsync } from \"./execAsync\"\r\n\r\nexport type UnzipOptions = {\r\n /**\r\n * 要解压的文件\r\n */\r\n input: string\r\n /**\r\n * 解压到的目标文件夹位置\r\n */\r\n output: string\r\n /**\r\n * 压缩文件时的工作目录\r\n */\r\n cwd?: string\r\n}\r\n\r\n/**\r\n * 使用 7z 命令解压文件\r\n * - 如果没有安装 7z,请先安装 7z 后再执行\r\n * - 下载地址:https://www.7-zip.org/download.html\r\n * - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中\r\n * 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\r\n * 2. 在系统变量中找到并选中 Path,点击编辑\r\n * 3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定\r\n * 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\r\n * 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\r\n */\r\nexport async function unzip({ input, output, cwd }: UnzipOptions) {\r\n await which(\"7z\")\r\n return await execAsync(`7z x ${input} -o${output}`, { cwd })\r\n}\r\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS;AAiBlB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,KAAKA,CAAC;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAkB,CAAC,EAAE;EAC9D,MAAML,KAAK,CAAC,IAAI,CAAC;EACjB,OAAO,MAAMC,SAAS,CAAE,QAAOE,KAAM,MAAKC,MAAO,EAAC,EAAE;IAAEC;EAAI,CAAC,CAAC;AAChE"}
|
package/dist/esm/utils/zip.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ export type ZipOptions = {
|
|
|
19
19
|
* 是否加密
|
|
20
20
|
*/
|
|
21
21
|
password?: string;
|
|
22
|
+
/**
|
|
23
|
+
* 压缩文件时的工作目录
|
|
24
|
+
*/
|
|
25
|
+
cwd?: string;
|
|
22
26
|
};
|
|
23
27
|
/**
|
|
24
28
|
* 使用 7z 命令压缩文件
|
|
@@ -31,4 +35,4 @@ export type ZipOptions = {
|
|
|
31
35
|
* 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功
|
|
32
36
|
* 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确
|
|
33
37
|
*/
|
|
34
|
-
export declare function zip({ input, output, thread, level, password }: ZipOptions): Promise<
|
|
38
|
+
export declare function zip({ input, output, thread, level, password, cwd }: ZipOptions): Promise<string>;
|
package/dist/esm/utils/zip.js
CHANGED
|
@@ -17,11 +17,14 @@ export async function zip({
|
|
|
17
17
|
output,
|
|
18
18
|
thread = "auto",
|
|
19
19
|
level,
|
|
20
|
-
password
|
|
20
|
+
password,
|
|
21
|
+
cwd
|
|
21
22
|
}) {
|
|
22
23
|
await which("7z");
|
|
23
24
|
input = Array.isArray(input) ? input.join(" ") : input;
|
|
24
25
|
if (thread === "max") thread = cpus().length;
|
|
25
|
-
return await execAsync(`7z a ${output} ${input} -mmt=${thread === "auto" ? "on" : thread}${typeof level === "number" ? ` -mx=${level}` : ""}${password ? ` -p${password}` : ""}
|
|
26
|
+
return await execAsync(`7z a ${output} ${input} -mmt=${thread === "auto" ? "on" : thread}${typeof level === "number" ? ` -mx=${level}` : ""}${password ? ` -p${password}` : ""}`, {
|
|
27
|
+
cwd
|
|
28
|
+
});
|
|
26
29
|
}
|
|
27
30
|
//# sourceMappingURL=zip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["cpus","which","execAsync","zip","input","output","thread","level","password","Array","isArray","join","length"],"sources":["../../../src/utils/zip.ts"],"sourcesContent":["import { cpus } from \"os\"\r\nimport which from \"which\"\r\nimport { execAsync } from \"./execAsync\"\r\n\r\nexport type ZipOptions = {\r\n /**\r\n * 要压缩的文件\r\n */\r\n input: string | string[]\r\n /**\r\n * 压缩到的目标位置,文件名的后缀就是压缩格式,例如:.zip、.7z\r\n */\r\n output: string\r\n /**\r\n * 线程数\r\n */\r\n thread?: number | \"auto\" | \"max\"\r\n /**\r\n * 压缩等级,0-9\r\n */\r\n level?: number\r\n /**\r\n * 是否加密\r\n */\r\n password?: string\r\n}\r\n\r\n/**\r\n * 使用 7z 命令压缩文件\r\n * - 如果没有安装 7z,请先安装 7z 后再执行\r\n * - 下载地址:https://www.7-zip.org/download.html\r\n * - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中\r\n * 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\r\n * 2. 在系统变量中找到并选中 Path,点击编辑\r\n * 3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定\r\n * 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\r\n * 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\r\n */\r\nexport async function zip({ input, output, thread = \"auto\", level, password }: ZipOptions) {\r\n await which(\"7z\")\r\n input = Array.isArray(input) ? input.join(\" \") : input\r\n if (thread === \"max\") thread = cpus().length\r\n return await execAsync(`7z a ${output} ${input} -mmt=${thread === \"auto\" ? \"on\" : thread}${typeof level === \"number\" ? ` -mx=${level}` : \"\"}${password ? ` -p${password}` : \"\"}
|
|
1
|
+
{"version":3,"names":["cpus","which","execAsync","zip","input","output","thread","level","password","cwd","Array","isArray","join","length"],"sources":["../../../src/utils/zip.ts"],"sourcesContent":["import { cpus } from \"os\"\r\nimport which from \"which\"\r\nimport { execAsync } from \"./execAsync\"\r\n\r\nexport type ZipOptions = {\r\n /**\r\n * 要压缩的文件\r\n */\r\n input: string | string[]\r\n /**\r\n * 压缩到的目标位置,文件名的后缀就是压缩格式,例如:.zip、.7z\r\n */\r\n output: string\r\n /**\r\n * 线程数\r\n */\r\n thread?: number | \"auto\" | \"max\"\r\n /**\r\n * 压缩等级,0-9\r\n */\r\n level?: number\r\n /**\r\n * 是否加密\r\n */\r\n password?: string\r\n /**\r\n * 压缩文件时的工作目录\r\n */\r\n cwd?: string\r\n}\r\n\r\n/**\r\n * 使用 7z 命令压缩文件\r\n * - 如果没有安装 7z,请先安装 7z 后再执行\r\n * - 下载地址:https://www.7-zip.org/download.html\r\n * - 如果已经安装,请按照以下步骤将 7z 添加到环境变量中\r\n * 1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\r\n * 2. 在系统变量中找到并选中 Path,点击编辑\r\n * 3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定\r\n * 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\r\n * 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\r\n */\r\nexport async function zip({ input, output, thread = \"auto\", level, password, cwd }: ZipOptions) {\r\n await which(\"7z\")\r\n input = Array.isArray(input) ? input.join(\" \") : input\r\n if (thread === \"max\") thread = cpus().length\r\n return await execAsync(`7z a ${output} ${input} -mmt=${thread === \"auto\" ? \"on\" : thread}${typeof level === \"number\" ? ` -mx=${level}` : \"\"}${password ? ` -p${password}` : \"\"}`, { cwd })\r\n}\r\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,IAAI;AACzB,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,SAAS;AA6BlB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,GAAGA,CAAC;EAAEC,KAAK;EAAEC,MAAM;EAAEC,MAAM,GAAG,MAAM;EAAEC,KAAK;EAAEC,QAAQ;EAAEC;AAAgB,CAAC,EAAE;EAC5F,MAAMR,KAAK,CAAC,IAAI,CAAC;EACjBG,KAAK,GAAGM,KAAK,CAACC,OAAO,CAACP,KAAK,CAAC,GAAGA,KAAK,CAACQ,IAAI,CAAC,GAAG,CAAC,GAAGR,KAAK;EACtD,IAAIE,MAAM,KAAK,KAAK,EAAEA,MAAM,GAAGN,IAAI,CAAC,CAAC,CAACa,MAAM;EAC5C,OAAO,MAAMX,SAAS,CAAE,QAAOG,MAAO,IAAGD,KAAM,SAAQE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAGA,MAAO,GAAE,OAAOC,KAAK,KAAK,QAAQ,GAAI,QAAOA,KAAM,EAAC,GAAG,EAAG,GAAEC,QAAQ,GAAI,MAAKA,QAAS,EAAC,GAAG,EAAG,EAAC,EAAE;IAAEC;EAAI,CAAC,CAAC;AAC9L"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soda-nodejs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"father": "^4.5.0-rc.2"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"iconv-lite": "^0.6.3",
|
|
31
32
|
"which": "^4.0.0"
|
|
32
33
|
},
|
|
33
34
|
"scripts": {
|
package/src/index.ts
CHANGED
package/src/utils/execAsync.ts
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import { exec, ExecOptions } from "child_process"
|
|
2
2
|
import { ObjectEncodingOptions } from "fs"
|
|
3
|
+
import iconv, { Options } from "iconv-lite"
|
|
3
4
|
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export type IconvDecodeOptions = {
|
|
6
|
+
encoding: string
|
|
7
|
+
options?: Options
|
|
7
8
|
}
|
|
8
9
|
|
|
9
|
-
export async function execAsync(command: string): Promise<
|
|
10
|
-
export async function execAsync(command: string, options: { encoding: "buffer" | null } & ExecOptions): Promise<
|
|
11
|
-
export async function execAsync(command: string, options: { encoding:
|
|
12
|
-
export async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<
|
|
13
|
-
export async function execAsync(command: string, options: ExecOptions): Promise<
|
|
14
|
-
export async function execAsync(command: string, options:
|
|
10
|
+
export async function execAsync(command: string): Promise<string>
|
|
11
|
+
export async function execAsync(command: string, options: { encoding: "buffer" | null } & ExecOptions): Promise<Buffer>
|
|
12
|
+
export async function execAsync(command: string, options: { encoding: "buffer" | null } & ExecOptions & { decode: IconvDecodeOptions }): Promise<string>
|
|
13
|
+
export async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<string>
|
|
14
|
+
export async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions): Promise<string | Buffer>
|
|
15
|
+
export async function execAsync(command: string, options: { encoding: BufferEncoding } & ExecOptions & { decode: IconvDecodeOptions }): Promise<string>
|
|
16
|
+
export async function execAsync(command: string, options: ExecOptions): Promise<string>
|
|
17
|
+
export async function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions) | undefined | null): Promise<string | Buffer>
|
|
18
|
+
export async function execAsync(command: string, options: (ObjectEncodingOptions & ExecOptions & { decode: IconvDecodeOptions }) | undefined | null): Promise<string>
|
|
15
19
|
export async function execAsync(command: string, options?: any) {
|
|
16
|
-
|
|
20
|
+
const decode = options?.decode as IconvDecodeOptions | undefined
|
|
21
|
+
if (typeof options === "object" && options !== null && options.decode) {
|
|
22
|
+
const { decode, ...rest } = options as { decode: IconvDecodeOptions }
|
|
23
|
+
options = rest
|
|
24
|
+
}
|
|
25
|
+
return await new Promise<string | Buffer>((resolve, reject) => {
|
|
17
26
|
exec(command, options, (error, stdout, stderr) => {
|
|
18
|
-
if (error)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
resolve({ stdout, stderr })
|
|
27
|
+
if (error) return reject(error)
|
|
28
|
+
// if (stderr) console.warn(stderr)
|
|
29
|
+
if (decode && stdout instanceof Buffer) return resolve(iconv.decode(stdout, decode.encoding, decode.options))
|
|
30
|
+
resolve(stdout)
|
|
23
31
|
})
|
|
24
32
|
})
|
|
25
33
|
}
|
package/src/utils/unzip.ts
CHANGED
|
@@ -10,6 +10,10 @@ export type UnzipOptions = {
|
|
|
10
10
|
* 解压到的目标文件夹位置
|
|
11
11
|
*/
|
|
12
12
|
output: string
|
|
13
|
+
/**
|
|
14
|
+
* 压缩文件时的工作目录
|
|
15
|
+
*/
|
|
16
|
+
cwd?: string
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
/**
|
|
@@ -23,7 +27,7 @@ export type UnzipOptions = {
|
|
|
23
27
|
* 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功
|
|
24
28
|
* 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确
|
|
25
29
|
*/
|
|
26
|
-
export async function unzip({ input, output }: UnzipOptions) {
|
|
30
|
+
export async function unzip({ input, output, cwd }: UnzipOptions) {
|
|
27
31
|
await which("7z")
|
|
28
|
-
return await execAsync(`7z x ${input} -o${output}
|
|
32
|
+
return await execAsync(`7z x ${input} -o${output}`, { cwd })
|
|
29
33
|
}
|
package/src/utils/zip.ts
CHANGED
|
@@ -23,6 +23,10 @@ export type ZipOptions = {
|
|
|
23
23
|
* 是否加密
|
|
24
24
|
*/
|
|
25
25
|
password?: string
|
|
26
|
+
/**
|
|
27
|
+
* 压缩文件时的工作目录
|
|
28
|
+
*/
|
|
29
|
+
cwd?: string
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
/**
|
|
@@ -36,9 +40,9 @@ export type ZipOptions = {
|
|
|
36
40
|
* 4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功
|
|
37
41
|
* 5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确
|
|
38
42
|
*/
|
|
39
|
-
export async function zip({ input, output, thread = "auto", level, password }: ZipOptions) {
|
|
43
|
+
export async function zip({ input, output, thread = "auto", level, password, cwd }: ZipOptions) {
|
|
40
44
|
await which("7z")
|
|
41
45
|
input = Array.isArray(input) ? input.join(" ") : input
|
|
42
46
|
if (thread === "max") thread = cpus().length
|
|
43
|
-
return await execAsync(`7z a ${output} ${input} -mmt=${thread === "auto" ? "on" : thread}${typeof level === "number" ? ` -mx=${level}` : ""}${password ? ` -p${password}` : ""}
|
|
47
|
+
return await execAsync(`7z a ${output} ${input} -mmt=${thread === "auto" ? "on" : thread}${typeof level === "number" ? ` -mx=${level}` : ""}${password ? ` -p${password}` : ""}`, { cwd })
|
|
44
48
|
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/utils/check7zip.ts
|
|
30
|
-
var check7zip_exports = {};
|
|
31
|
-
__export(check7zip_exports, {
|
|
32
|
-
check7zip: () => check7zip
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(check7zip_exports);
|
|
35
|
-
var import_which = __toESM(require("which"));
|
|
36
|
-
async function check7zip() {
|
|
37
|
-
try {
|
|
38
|
-
await (0, import_which.default)("7z");
|
|
39
|
-
return true;
|
|
40
|
-
} catch (error) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
-
0 && (module.exports = {
|
|
46
|
-
check7zip
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=check7zip.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/utils/check7zip.ts"],
|
|
4
|
-
"sourcesContent": ["import which from \"which\"\r\n\r\n/**\r\n * 检测 7z 命令是否存在\r\n */\r\nexport async function check7zip() {\r\n try {\r\n await which(\"7z\")\r\n return true\r\n } catch (error) {\r\n return false\r\n }\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAKlB,eAAsB,YAAY;AAC9B,MAAI;AACA,cAAM,aAAAA,SAAM,IAAI;AAChB,WAAO;AAAA,EACX,SAAS,OAAP;AACE,WAAO;AAAA,EACX;AACJ;",
|
|
6
|
-
"names": ["which"]
|
|
7
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/utils/install7zip.ts
|
|
20
|
-
var install7zip_exports = {};
|
|
21
|
-
__export(install7zip_exports, {
|
|
22
|
-
install7zip: () => install7zip
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(install7zip_exports);
|
|
25
|
-
function install7zip() {
|
|
26
|
-
console.log("检测到您的系统没有安装 7z,请先安装 7z 后再执行");
|
|
27
|
-
console.log("下载地址:https://www.7-zip.org/download.html");
|
|
28
|
-
console.log("如果已经安装,请按照以下步骤将 7z 添加到环境变量中");
|
|
29
|
-
console.log("1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量");
|
|
30
|
-
console.log("2. 在系统变量中找到并选中 Path,点击编辑");
|
|
31
|
-
console.log("3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定");
|
|
32
|
-
console.log("4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功");
|
|
33
|
-
console.log("5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确");
|
|
34
|
-
}
|
|
35
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
-
0 && (module.exports = {
|
|
37
|
-
install7zip
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=install7zip.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/utils/install7zip.ts"],
|
|
4
|
-
"sourcesContent": ["/**\r\n * 检测到没有安装 7z 时的提示信息\r\n */\r\nexport function install7zip() {\r\n console.log(\"检测到您的系统没有安装 7z,请先安装 7z 后再执行\")\r\n console.log(\"下载地址:https://www.7-zip.org/download.html\")\r\n console.log(\"如果已经安装,请按照以下步骤将 7z 添加到环境变量中\")\r\n console.log(\"1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\")\r\n console.log(\"2. 在系统变量中找到并选中 Path,点击编辑\")\r\n console.log(\"3. 点击新建,输入 7z 的安装路径(默认是 C:\\\\Program Files\\\\7-Zip),点击确定\")\r\n console.log(\"4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\")\r\n console.log(\"5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\")\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,cAAc;AAC1B,UAAQ,IAAI,6BAA6B;AACzC,UAAQ,IAAI,0CAA0C;AACtD,UAAQ,IAAI,6BAA6B;AACzC,UAAQ,IAAI,qCAAqC;AACjD,UAAQ,IAAI,0BAA0B;AACtC,UAAQ,IAAI,wDAAwD;AACpE,UAAQ,IAAI,mCAAmC;AAC/C,UAAQ,IAAI,uCAAuC;AACvD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["which","check7zip","error"],"sources":["../../../src/utils/check7zip.ts"],"sourcesContent":["import which from \"which\"\r\n\r\n/**\r\n * 检测 7z 命令是否存在\r\n */\r\nexport async function check7zip() {\r\n try {\r\n await which(\"7z\")\r\n return true\r\n } catch (error) {\r\n return false\r\n }\r\n}\r\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;;AAEzB;AACA;AACA;AACA,OAAO,eAAeC,SAASA,CAAA,EAAG;EAC9B,IAAI;IACA,MAAMD,KAAK,CAAC,IAAI,CAAC;IACjB,OAAO,IAAI;EACf,CAAC,CAAC,OAAOE,KAAK,EAAE;IACZ,OAAO,KAAK;EAChB;AACJ"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 检测到没有安装 7z 时的提示信息
|
|
3
|
-
*/
|
|
4
|
-
export function install7zip() {
|
|
5
|
-
console.log("检测到您的系统没有安装 7z,请先安装 7z 后再执行");
|
|
6
|
-
console.log("下载地址:https://www.7-zip.org/download.html");
|
|
7
|
-
console.log("如果已经安装,请按照以下步骤将 7z 添加到环境变量中");
|
|
8
|
-
console.log("1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量");
|
|
9
|
-
console.log("2. 在系统变量中找到并选中 Path,点击编辑");
|
|
10
|
-
console.log("3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定");
|
|
11
|
-
console.log("4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功");
|
|
12
|
-
console.log("5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确");
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=install7zip.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["install7zip","console","log"],"sources":["../../../src/utils/install7zip.ts"],"sourcesContent":["/**\r\n * 检测到没有安装 7z 时的提示信息\r\n */\r\nexport function install7zip() {\r\n console.log(\"检测到您的系统没有安装 7z,请先安装 7z 后再执行\")\r\n console.log(\"下载地址:https://www.7-zip.org/download.html\")\r\n console.log(\"如果已经安装,请按照以下步骤将 7z 添加到环境变量中\")\r\n console.log(\"1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量\")\r\n console.log(\"2. 在系统变量中找到并选中 Path,点击编辑\")\r\n console.log(\"3. 点击新建,输入 7z 的安装路径(默认是 C:\\\\Program Files\\\\7-Zip),点击确定\")\r\n console.log(\"4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功\")\r\n console.log(\"5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确\")\r\n}\r\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,SAASA,WAAWA,CAAA,EAAG;EAC1BC,OAAO,CAACC,GAAG,CAAC,6BAA6B,CAAC;EAC1CD,OAAO,CAACC,GAAG,CAAC,0CAA0C,CAAC;EACvDD,OAAO,CAACC,GAAG,CAAC,6BAA6B,CAAC;EAC1CD,OAAO,CAACC,GAAG,CAAC,qCAAqC,CAAC;EAClDD,OAAO,CAACC,GAAG,CAAC,0BAA0B,CAAC;EACvCD,OAAO,CAACC,GAAG,CAAC,wDAAwD,CAAC;EACrED,OAAO,CAACC,GAAG,CAAC,mCAAmC,CAAC;EAChDD,OAAO,CAACC,GAAG,CAAC,uCAAuC,CAAC;AACxD"}
|
package/src/utils/check7zip.ts
DELETED
package/src/utils/install7zip.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 检测到没有安装 7z 时的提示信息
|
|
3
|
-
*/
|
|
4
|
-
export function install7zip() {
|
|
5
|
-
console.log("检测到您的系统没有安装 7z,请先安装 7z 后再执行")
|
|
6
|
-
console.log("下载地址:https://www.7-zip.org/download.html")
|
|
7
|
-
console.log("如果已经安装,请按照以下步骤将 7z 添加到环境变量中")
|
|
8
|
-
console.log("1. 设置 → 系统 → 右侧系统信息 → 高级系统设置 → 环境变量")
|
|
9
|
-
console.log("2. 在系统变量中找到并选中 Path,点击编辑")
|
|
10
|
-
console.log("3. 点击新建,输入 7z 的安装路径(默认是 C:\\Program Files\\7-Zip),点击确定")
|
|
11
|
-
console.log("4. 重启终端,输入 7z,如果出现 7z 的版本信息,则安装成功")
|
|
12
|
-
console.log("5. 如果没有出现版本信息,请重启电脑,或者检查 7z 的安装路径是否正确")
|
|
13
|
-
}
|