js-dev-tool 1.2.24 → 1.2.26

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-dev-tool",
3
- "version": "1.2.24",
3
+ "version": "1.2.26",
4
4
  "type": "commonjs",
5
5
  "bin": {
6
6
  "jstool": "tools.js",
@@ -39,6 +39,14 @@
39
39
  "import": "./progress/*.js",
40
40
  "require": "./progress/*.js"
41
41
  },
42
+ "./scripts/wp/*": {
43
+ "types": "./scripts/wp/*.d.mts",
44
+ "import": "./scripts/wp/*.mjs"
45
+ },
46
+ "./scripts/vitest/*": {
47
+ "types": "./scripts/vitest/*.d.mts",
48
+ "import": "./scripts/vitest/*.mjs"
49
+ },
42
50
  "./basic-types": {
43
51
  "types": "./basic-types.d.ts"
44
52
  }
@@ -66,18 +74,18 @@
66
74
  "progress",
67
75
  "scripts",
68
76
  "tool-lib",
69
- "./index.js",
70
- "./tools.js",
71
- "./utils.js",
72
- "./tsconfig.json",
77
+ "index.js",
78
+ "tools.js",
79
+ "utils.js",
80
+ "tsconfig.json",
73
81
  "!tool-lib/cjbm-*",
74
- "!unzip.ts",
82
+ "!*zip.{j,t}s",
75
83
  "!scripts/bin",
76
84
  "!publish-version.json",
77
85
  "!scripts/*.mjs",
78
86
  "!scripts/smoke",
79
87
  "!regex-test.ts",
80
- "!extras/npm",
88
+ "!extras/{npm,navigator-uadata*}",
81
89
  "!/**/*.png",
82
90
  "!*@*.*",
83
91
  "!*fragments*",
@@ -85,16 +93,15 @@
85
93
  ],
86
94
  "peerDependencies": {
87
95
  "archiver": "^7.0.1",
88
- "webpack": "*"
96
+ "webpack": "*",
97
+ "typescript": "^6"
89
98
  },
90
99
  "dependencies": {
91
- "colors.ts": "^1.0.20",
92
- "fflate": "^0.8.3",
100
+ "colors.tsz": "^1.6.4",
93
101
  "literate-regex": "^0.6.11",
94
- "mini-semaphore": "^1.5.4",
95
102
  "replace": "^1.2.2",
96
103
  "rm-cstyle-cmts": "^3.4.4",
97
- "terser": "^5.48.0",
104
+ "terser": "^5.49.0",
98
105
  "tin-args": "^0.1.7",
99
106
  "ts-cc-map": "^1.1.0"
100
107
  }
@@ -0,0 +1,17 @@
1
+ import type ts from "typescript";
2
+ /**
3
+ * + when could refers `vite` types
4
+ *
5
+ * @import * as NsVite from "vite";
6
+ *
7
+ * ```
8
+ * import * as NsVite from "vite";
9
+ * // @ returns {NsVite.Plugin}
10
+ * ```
11
+ *
12
+ * @template {unknown} R
13
+ * @param {string=} cwd
14
+ * @param {ts.CompilerOptions=} compilerOpt
15
+ * @param {(tsEmitFileName: string) => boolean=} validateFileName
16
+ */
17
+ export declare function tsConstEnumPlugin<R>(cwd?: string, compilerOpt?: ts.CompilerOptions, validateFileName?: (fileName: string) => boolean): R;
@@ -0,0 +1,78 @@
1
+ /*!
2
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3
+ // Copyright (C) 2026 jeffy-g <hirotom1107@gmail.com>
4
+ // Released under the MIT license
5
+ // https://opensource.org/licenses/mit-license.php
6
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
+ */
8
+ /**
9
+ * @file lib/ts-const-enum-transform.mjs
10
+ */
11
+ import path from "node:path";
12
+ import ts from "typescript";
13
+ /** @type {ts.CompilerOptions} */
14
+ const compilerOptDefault = {
15
+ declaration: false,
16
+ declarationMap: false,
17
+ emitDeclarationOnly: false,
18
+ noEmit: false,
19
+ preserveConstEnums: false,
20
+ sourceMap: false,
21
+ };
22
+ /**
23
+ * + when could refers `vite` types
24
+ *
25
+ * &#64;import * as NsVite from "vite";
26
+ *
27
+ * ```
28
+ * import * as NsVite from "vite";
29
+ * // @ returns {NsVite.Plugin}
30
+ * ```
31
+ *
32
+ * @template {unknown} R
33
+ * @param {string=} cwd
34
+ * @param {ts.CompilerOptions=} compilerOpt
35
+ * @param {(tsEmitFileName: string) => boolean=} validateFileName
36
+ */
37
+ export function tsConstEnumPlugin(
38
+ cwd,
39
+ compilerOpt,
40
+ validateFileName = (fileName) => /\.(?:c|m)?jsx?$/.test(fileName)
41
+ ) {
42
+ /** @type {ts.Program | undefined} */
43
+ let program;
44
+ const dirname = path.dirname;
45
+ const normalize = path.normalize;
46
+ cwd ??= process.cwd();
47
+ const getProgram = () => {
48
+ if (program) return program;
49
+ const configPath = ts.findConfigFile(cwd, ts.sys.fileExists, "tsconfig.json");
50
+ if (!configPath) throw new Error("tsconfig.json was not found.");
51
+ const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
52
+ const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, dirname(configPath), {
53
+ ...compilerOptDefault, ...compilerOpt
54
+ });
55
+ program = ts.createProgram(parsed.fileNames, parsed.options);
56
+ return program;
57
+ };
58
+ return /** @type {R} */({
59
+ name: "ts-const-enum-transform",
60
+ enforce: "pre",
61
+ handleHotUpdate() {
62
+ program = undefined;
63
+ },
64
+ /** @type {(code: string, id: string) => { code: string, map: null } | null} */
65
+ transform(_code, id) {
66
+ const tsc = getProgram();
67
+ const sourceFile = tsc.getSourceFile(
68
+ normalize(id.split("?")[0])
69
+ );
70
+ if (!sourceFile) return null;
71
+ let code = "";
72
+ tsc.emit(sourceFile, (outputName, outputText) => {
73
+ if (validateFileName(outputName)) code = outputText;
74
+ });
75
+ return code ? { code, map: null } : null;
76
+ },
77
+ });
78
+ }
@@ -0,0 +1,52 @@
1
+ /*!
2
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3
+ // Copyright (C) 2020 jeffy-g <hirotom1107@gmail.com>
4
+ // Released under the MIT license
5
+ // https://opensource.org/licenses/mit-license.php
6
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
+ */
8
+ /// <reference path="../../basic-types.d.ts" preserve="true"/>
9
+ import type webpack from "webpack";
10
+ export type TWpConfigRequiredKeys = "name" | "mode" | "target" | "entry" | "output" | "module" | "externalsPresets" | "resolve" | "devtool" | "plugins" | "profile" | "cache" | "recordsPath" | "externals" | "experiments";
11
+ export type WpConfig = RequireKeys<webpack.Configuration, TWpConfigRequiredKeys>;
12
+ export type TExtraOptions = { beautify?: true; forceSourceMap?: true, altEntry?: WpConfig["entry"]; tsconfig?: string; logsSubDir?: string };
13
+ export type TModuleIdMaker = (originId: string, module: webpack.Module) => string | number;
14
+ export declare const CWD: string;
15
+ /**
16
+ * __reduce webpack size by shorten modId__
17
+ *
18
+ * @param {TModuleIdMaker} maker
19
+ */
20
+ export declare const mapModuleIds: (maker: TModuleIdMaker) => (compiler: webpack.Compiler) => void;
21
+ export declare const numberMaker: TModuleIdMaker;
22
+ /**
23
+ * + About `entry` shape
24
+ *
25
+ * ```
26
+ * // "index.js"
27
+ * getIndexName("./src/index.js");
28
+ * getIndexName({ index: "./src/index.js" });
29
+ * getIndexName(["./src/index.js"]);
30
+ *
31
+ * // "hoge"
32
+ * getIndexName({ hoge: "./src/index.js" });
33
+ *
34
+ * // undefined
35
+ * getIndexName({});
36
+ * ```
37
+ * @param entry
38
+ */
39
+ export declare function getIndexName(entry: NonNullable<WpConfig["entry"]>): string | undefined;
40
+ /**
41
+ * CAVEAT: `resolve`, `entry`, `externals`, `module`, `optimization` property is __empty object__
42
+ *
43
+ * @param target
44
+ * @param output NOTE: On config name creation refers of `library.type`. if not specified use `commonjs2`
45
+ * @param [mode] default is __`"production"`__
46
+ * @param {TExtraOptions=} extraOpt see {@link TExtraOptions}
47
+ * @return {WpConfig}
48
+ * @version 2.0
49
+ */
50
+ export declare const createWebpackConfig: (target: WpConfig["target"], output: WpConfig["output"], mode?: WpConfig["mode"], extraOpt?: TExtraOptions) => WpConfig;
51
+ export type TCreateWebpackConfigParameters = Parameters<typeof createWebpackConfig>;
52
+ export type TWebpackConfigParameters = [TCreateWebpackConfigParameters[0], TCreateWebpackConfigParameters[1], altEntry?: webpack.EntryObject, tsconfig?: string];
@@ -0,0 +1,165 @@
1
+ /*!
2
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3
+ // Copyright (C) 2020 jeffy-g <hirotom1107@gmail.com>
4
+ // Released under the MIT license
5
+ // https://opensource.org/licenses/mit-license.php
6
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
+ */
8
+ /// <reference path="../../basic-types.d.ts" preserve="true"/>
9
+ /**
10
+ * @file scripts/wp/webpack.config.util.mjs
11
+ */
12
+ import * as path from "node:path";
13
+ import { fileURLToPath } from "node:url";
14
+ import webpack from "webpack";
15
+ import * as progress from "./wp-progress.mjs";
16
+ const configFileName = fileURLToPath(import.meta.url);
17
+ export const CWD = process.cwd();
18
+ /**
19
+ * @typedef {(originId: string, module: webpack.Module) => string | number} TModuleIdMaker
20
+ */
21
+ /**
22
+ * __reduce webpack size by shorten modId__
23
+ *
24
+ * @param {TModuleIdMaker} maker
25
+ * @returns
26
+ */
27
+ export const mapModuleIds = maker => (/** @type {webpack.Compiler} */compiler) => {
28
+ const context = /** @type {string} */(compiler.options.context);
29
+ compiler.hooks.compilation.tap("ChangeModuleIdsPlugin", compilation => {
30
+ compilation.hooks.beforeModuleIds.tap("ChangeModuleIdsPlugin", modules => {
31
+ const chunkGraph = compilation.chunkGraph;
32
+ for (const module of modules) {
33
+ if (module.libIdent) {
34
+ const origId = module.libIdent({ context });
35
+ if (!origId) continue;
36
+ chunkGraph.setModuleId(module, maker(origId, module));
37
+ }
38
+ }
39
+ });
40
+ });
41
+ };
42
+ /** @type {TModuleIdMaker} */
43
+ export const numberMaker = ((cache) => {
44
+ let idx = 0;
45
+ return (oid, mod) => {
46
+ let nid = cache.get(oid);
47
+ if (typeof nid !== "number") {
48
+ cache.set(oid, (nid = idx++));
49
+ }
50
+ return nid;
51
+ };
52
+ })(/** @type {Map<string, number>} */(new Map()));
53
+ /**
54
+ * + About `entry` shape
55
+ *
56
+ * ```
57
+ * // "index.js"
58
+ * getIndexName("./src/index.js");
59
+ * getIndexName({ index: "./src/index.js" });
60
+ * getIndexName(["./src/index.js"]);
61
+ *
62
+ * // "hoge"
63
+ * getIndexName({ hoge: "./src/index.js" });
64
+ *
65
+ * // undefined
66
+ * getIndexName({});
67
+ * ```
68
+ * @param {NonNullable<WpConfig["entry"]>} entry
69
+ */
70
+ export function getIndexName(entry) {
71
+ /** @type {string=} */
72
+ let indexPath;
73
+ if (typeof entry === "string") indexPath = entry;
74
+ else {
75
+ const path = /** @type {webpack.EntryObject} */(entry).index || /** @type {webpack.EntryObject} */(entry).main;
76
+ if (typeof path === "string") indexPath = path;
77
+ else {
78
+ if (Array.isArray(entry)) indexPath = entry[0];
79
+ else if (typeof entry === "object") return Object.keys(entry)[0];
80
+ }
81
+ }
82
+ if (typeof indexPath === "string") return path.basename(indexPath);
83
+ }
84
+ /**
85
+ * @typedef {"name" | "mode" | "target" | "entry" | "output" | "module" | "externalsPresets" | "resolve" | "devtool" | "plugins" | "profile" | "cache" | "recordsPath" | "externals" | "experiments"} TWpConfigRequiredKeys
86
+ * @typedef {RequireKeys<webpack.Configuration, TWpConfigRequiredKeys>} WpConfig
87
+ * @typedef {{ beautify?: true; forceSourceMap?: true, altEntry?: WpConfig["entry"]; tsconfig?: string; logsSubDir?: string }} TExtraOptions
88
+ */
89
+ /**
90
+ * @typedef {"standard" | "custom"=} TWPProgressType
91
+ */
92
+ /**
93
+ * @date 2026/06/19 09:55:39
94
+ */
95
+ const wpProgressType = /** @type {TWPProgressType} */(process.env.WP_PROGRESS_TYPE);
96
+ /**
97
+ * CAVEAT: `resolve`, `entry`, `externals`, `module`, `optimization` property is __empty object__
98
+ *
99
+ * @param {WpConfig["target"]} target
100
+ * @param {WpConfig["output"]} output NOTE: On config name creation refers of `library.type`. if not specified use `commonjs2`
101
+ * @param {WpConfig["mode"]=} mode default is __`"production"`__
102
+ * @param {TExtraOptions=} extraOpt see {@link TExtraOptions}
103
+ * @return {WpConfig}
104
+ * @version 2.0
105
+ * @date 2022/3/20 - update jsdoc, added new parameter `extraOpt`
106
+ */
107
+ export const createWebpackConfig = (target, output, mode = "production", extraOpt = {}) => {
108
+ const {
109
+ altEntry,
110
+ forceSourceMap,
111
+ logsSubDir = "webpack"
112
+ } = extraOpt;
113
+ /**
114
+ * @type {WpConfig["entry"]}
115
+ */
116
+ const entry = altEntry ?? {};
117
+ const mtype = /** @type {webpack.LibraryOptions} */(output.library)?.type ?? "commonjs2";
118
+ const mainName = `${target}@${mtype}_${getIndexName(entry) ?? "anonymous"}`;
119
+ const outputModule = mtype === "module";
120
+ /** @type {WpConfig} */
121
+ const configObject = {
122
+ name: `${mainName}-${mode}`,
123
+ mode,
124
+ target,
125
+ entry,
126
+ output,
127
+ module: {
128
+ rules: []
129
+ },
130
+ externals: {},
131
+ experiments: {},
132
+ externalsPresets: { node: true },
133
+ resolve: {
134
+ },
135
+ devtool: (forceSourceMap || mode === "development") ? "source-map" : false,
136
+ plugins: [],
137
+ optimization: {
138
+ },
139
+ profile: false,
140
+ cache: {
141
+ type: "filesystem",
142
+ buildDependencies: {
143
+ config: [configFileName],
144
+ },
145
+ },
146
+ recordsPath: `${CWD}/logs/${logsSubDir? logsSubDir + "/" : "" }webpack-module-ids_${mainName}.json`
147
+ };
148
+ if (outputModule) {
149
+ configObject.experiments = {
150
+ outputModule
151
+ };
152
+ }
153
+ if (wpProgressType === "custom") {
154
+ configObject.plugins.push(
155
+ new webpack.ProgressPlugin(
156
+ progress.getWebpackProgressPluginHandler(mainName)
157
+ )
158
+ );
159
+ }
160
+ return configObject;
161
+ };
162
+ /**
163
+ * @typedef {Parameters<typeof createWebpackConfig>} TCreateWebpackConfigParameters
164
+ * @typedef {[TCreateWebpackConfigParameters[0], TCreateWebpackConfigParameters[1], altEntry?: webpack.EntryObject, tsconfig?: string]} TWebpackConfigParameters
165
+ */
@@ -0,0 +1,3 @@
1
+ export type TWebpackProgressHandler = (percentage: number, message: string, ...args: string[]) => void;
2
+ declare const getWebpackProgressPluginHandler: (bunner: string) => TWebpackProgressHandler;
3
+ export { getWebpackProgressPluginHandler };
@@ -0,0 +1,95 @@
1
+ /*!
2
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
3
+ // Copyright (C) 2025 jeffy-g <hirotom1107@gmail.com>
4
+ // Released under the MIT license
5
+ // https://opensource.org/licenses/mit-license.php
6
+ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
+ */
8
+ /**
9
+ * @file scripts/wp/wp-progress.mjs
10
+ * @CAVEATS To enable `progress`, you need to install webpack and webpack-cli in package local.
11
+ */
12
+ import * as extras from "../../progress/progress-extras.js";
13
+ import * as lib from "../../common/index.js";
14
+ /**
15
+ * @typedef {(percentage: number, message: string, ...args: string[]) => void} TWebpackProgressHandler
16
+ * @typedef {(percentage: number, message: string, ...args: string[]) => Promise<void>} TWebpackProgressHandlerPromise unused
17
+ */
18
+ const PROGRESS_ROW_START = 4;
19
+ let rowStart = PROGRESS_ROW_START;
20
+ /**
21
+ * @param {number} pct
22
+ * @returns {string}
23
+ */
24
+ const formatPercentage = pct => `processing ${(pct * 100).toFixed(4)}%`;
25
+ /**
26
+ * @param {NodeJS.WriteStream} stream
27
+ */
28
+ const preparProgress = async (stream = process.stdout) => {
29
+ stream.write(`\x1b[${PROGRESS_ROW_START};1H`);
30
+ stream.write("\x1b[J");
31
+ };
32
+ /** @type {Map<string, number>} */
33
+ const rowsMap = new Map();
34
+ /** @type {(bunner: string) => TWebpackProgressHandler} */
35
+ const getWebpackProgressPluginHandler = ((bunner) => {
36
+ const cwd = process.cwd();
37
+ const render = lib.renderLine;
38
+ const cwdLen = cwd.length;
39
+ let dotted = 0;
40
+ const renderDot = () => {
41
+ process.stderr.write(".");
42
+ dotted++;
43
+ if (dotted % 100 === 0) {
44
+ process.stderr.write("\n");
45
+ }
46
+ };
47
+ const shortenProgress = (/** @type {number} */pct) => {
48
+ render(formatPercentage(pct));
49
+ pct >= 1 && (console.log(), dotted = 0);
50
+ };
51
+ let prepar = 0;
52
+ /**
53
+ * NOTE: 2025/11/17 15:58:11 - 複数の webpack process を確実に render する最適解だろう
54
+ *
55
+ * cursor position の取得、moveCursorTo などを試したが、期待する挙動に達するには壁があった...
56
+ *
57
+ * @type {TWebpackProgressHandler}
58
+ */
59
+ const v5Progress = /* async */ (percentage, message, ...args) => {
60
+ if (!prepar) {
61
+ /* await */ preparProgress();
62
+ prepar = 1;
63
+ }
64
+ if (!message) {
65
+ message = "- done -";
66
+ }
67
+ let pathOrPluginName = args.shift() || "";
68
+ if (pathOrPluginName) {
69
+ const x = pathOrPluginName.lastIndexOf(cwd) + 1;
70
+ if (x > 0) {
71
+ pathOrPluginName = pathOrPluginName.slice(x + cwdLen);
72
+ }
73
+ }
74
+ let row = rowsMap.get(bunner);
75
+ if (typeof row !== "number") {
76
+ rowsMap.set(bunner, (row = rowStart++));
77
+ }
78
+ render(
79
+ `[${bunner}]: ${(percentage * 100).toFixed(4)}%, process: [${message}]${pathOrPluginName ? `, info: [${pathOrPluginName}]` : ""}${args.length ? " - " : ""}${args.join(", ")}`, row
80
+ );
81
+ percentage >= 1 && console.log();
82
+ };
83
+ const processType = extras.checkENV();
84
+ if (processType === "ci" || process.env.CI_CODEX) {
85
+ return renderDot;
86
+ } else {
87
+ if (processType === "gitpod") {
88
+ return shortenProgress;
89
+ }
90
+ return v5Progress;
91
+ }
92
+ });
93
+ export {
94
+ getWebpackProgressPluginHandler
95
+ };
package/tools.js CHANGED
@@ -9,7 +9,7 @@
9
9
  */
10
10
  // @ts-check
11
11
  "use strict";
12
- require("colors.ts");
12
+ require("colors.tsz");
13
13
  const fs = require("fs");
14
14
  const path = require("path");
15
15
  const rmc = require("rm-cstyle-cmts");
package/scripts/unzip.js DELETED
@@ -1,29 +0,0 @@
1
- "use strict";
2
- const fs = require("fs");
3
- const fflate = require("fflate");
4
- const { unzip } = fflate;
5
- /**
6
- * @param {string} fileName
7
- */
8
- const decompress = (fileName) => {
9
- fs.readFile(fileName, null, (err, data) => {
10
- if (err) {
11
- console.error(err);
12
- } else {
13
- console.time(fileName);
14
- unzip(data, (err, unzipped) => {
15
- console.timeEnd(fileName);
16
- if (err) {
17
- console.error(err);
18
- return;
19
- }
20
- Object.entries(unzipped).forEach(([filename, data]) => {
21
- fs.writeFile(filename, data, null, () => {
22
- console.log("write:", filename);
23
- });
24
- });
25
- });
26
- }
27
- });
28
- };
29
- module.exports = decompress;
package/scripts/zip.js DELETED
@@ -1,86 +0,0 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const fflate = require("fflate");
4
- const { TextEncoder } = require("util");
5
- const ALREADY_COMPRESSED = [
6
- "7z", "aifc", "bz2", "doc", "docx",
7
- "gif", "gz", "heic", "heif", "jpeg",
8
- "jpg", "mov", "mp3", "mp4", "pdf",
9
- "png", "ppt", "pptx", "rar", "webm",
10
- "webp", "xls", "xlsx", "zip"
11
- ];
12
- /**
13
- * @param {string} fileName
14
- * @param {(out: Uint8Array | NodeJS.ErrnoException) => void} cb
15
- */
16
- const fileToU8 = (fileName, cb /* : (out: Uint8Array) => void */) => {
17
- fs.readFile(fileName, "utf8", (err, data) => {
18
- if (err) {
19
- cb(err);
20
- } else {
21
- cb(new TextEncoder().encode(data));
22
- }
23
- });
24
- };
25
- /**
26
- * @param {path.ParsedPath} parsedPath
27
- * @param {(out: Uint8Array | null) => void} callback
28
- * @param {string} [comment]
29
- */
30
- const processFile = function (parsedPath, callback, comment) {
31
- const filePath = `${parsedPath.dir}/${parsedPath.base}`;
32
- fileToU8(filePath, function (data) {
33
- if (data instanceof Uint8Array) {
34
- /** @type {fflate.AsyncZippable} */
35
- const zipObj = {
36
- [parsedPath.base]: [
37
- data, {
38
- level: ALREADY_COMPRESSED.indexOf(parsedPath.ext) === -1 ? 6 : 0,
39
- comment,
40
- },
41
- ],
42
- };
43
- console.time(filePath);
44
- fflate.zip(
45
- zipObj,
46
- {
47
- },
48
- function (err, out) {
49
- if (err) {
50
- console.log(err);
51
- callback(null);
52
- console.timeEnd(filePath);
53
- } else {
54
- console.timeEnd(filePath);
55
- callback(out);
56
- }
57
- },
58
- );
59
- } else {
60
- console.error(data);
61
- }
62
- });
63
- };
64
- /**
65
- * @param {string} inputPath
66
- * @param {string} [comment]
67
- * @param {string} [dest]
68
- */
69
- module.exports = function zip(inputPath, comment, dest) {
70
- let actualOutput = dest;
71
- const pp = path.parse(inputPath);
72
- processFile(
73
- pp,
74
- (out) => {
75
- if (out) {
76
- if (!actualOutput) {
77
- actualOutput = `${pp.dir ? pp.dir + "/" : ""}${pp.name}.zip`;
78
- }
79
- fs.writeFile(actualOutput, out, "binary", () => {
80
- console.log("done!!");
81
- });
82
- }
83
- },
84
- comment,
85
- );
86
- };