binary-collections 2.0.5 → 2.0.7
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/bin/bash-dummy +7 -2
- package/bin/clean-nodemodule +7 -2
- package/bin/clean-nodemodules +7 -2
- package/bin/dev +7 -2
- package/bin/empty +7 -2
- package/bin/git-diff.cmd +4 -0
- package/bin/git-fix-encoding +7 -2
- package/bin/git-fix-encoding.cmd +0 -0
- package/bin/git-reduce-size +7 -2
- package/bin/kill-process +7 -2
- package/bin/nodekill +7 -2
- package/bin/nodekill.cmd +0 -0
- package/bin/nodekill.ps1 +0 -0
- package/bin/prod +7 -2
- package/bin/rmfind +7 -2
- package/bin/rmpath +7 -2
- package/bin/rmx +9 -3
- package/bin/submodule +13 -2
- package/bin/submodule-install +7 -2
- package/bin/submodule-remove +7 -2
- package/lib/chunk-3LOB2P54.mjs +202 -0
- package/lib/chunk-4LEXWIIF.mjs +173 -0
- package/lib/chunk-BSD5CIRU.mjs +52 -0
- package/lib/chunk-FB6YIQYR.mjs +42 -0
- package/lib/chunk-JL32QDSH.mjs +20 -0
- package/lib/chunk-OKYLF2MU.mjs +53 -0
- package/lib/chunk-VXZQNLPU.mjs +23 -0
- package/lib/del-gradle.cjs +72 -0
- package/lib/del-gradle.d.mts +2 -0
- package/lib/del-gradle.d.ts +1 -0
- package/lib/del-gradle.js +15 -0
- package/lib/del-gradle.mjs +28 -0
- package/lib/del-node-modules.cjs +72 -0
- package/lib/del-node-modules.d.mts +2 -0
- package/lib/del-node-modules.d.ts +1 -0
- package/lib/del-node-modules.js +11 -15
- package/lib/del-node-modules.mjs +28 -0
- package/lib/del-ps.cjs +93 -0
- package/lib/del-ps.d.mts +2 -0
- package/lib/del-ps.d.ts +1 -0
- package/lib/del-ps.js +31 -0
- package/lib/del-ps.mjs +43 -0
- package/lib/del-yarn-caches.cjs +65 -0
- package/lib/del-yarn-caches.d.mts +2 -0
- package/lib/del-yarn-caches.d.ts +1 -0
- package/lib/del-yarn-caches.js +6 -9
- package/lib/del-yarn-caches.mjs +21 -0
- package/lib/find-node-modules-cli.cjs +59 -0
- package/lib/find-node-modules-cli.d.mts +1 -0
- package/lib/find-node-modules-cli.d.ts +2 -0
- package/lib/find-node-modules-cli.js +3 -0
- package/lib/find-node-modules-cli.mjs +14 -0
- package/lib/find-node-modules.cjs +34 -0
- package/lib/find-node-modules.d.mts +10 -0
- package/lib/find-node-modules.d.ts +9 -0
- package/lib/find-node-modules.js +41 -13
- package/lib/find-node-modules.mjs +7 -0
- package/lib/git-diff.cjs +74 -0
- package/lib/git-diff.d.cts +2 -0
- package/lib/git-diff.d.mts +87 -0
- package/lib/git-diff.d.ts +87 -0
- package/lib/git-diff.mjs +83 -0
- package/lib/git-purge.cjs +91 -0
- package/lib/git-purge.d.mts +2 -0
- package/lib/git-purge.d.ts +1 -0
- package/lib/git-purge.js +59 -0
- package/lib/git-purge.mjs +47 -0
- package/lib/index.cjs +92 -0
- package/lib/index.d.mts +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +8 -0
- package/lib/index.mjs +18 -0
- package/lib/npm-run-series.cjs +61 -0
- package/lib/npm-run-series.d.mts +1 -0
- package/lib/npm-run-series.d.ts +2 -0
- package/lib/npm-run-series.js +80 -39
- package/lib/npm-run-series.mjs +47 -0
- package/lib/package-resolutions.cjs +28 -0
- package/lib/package-resolutions.d.mts +25 -0
- package/lib/package-resolutions.d.ts +25 -0
- package/lib/package-resolutions.mjs +31 -0
- package/lib/ps/connected-domain.cjs +156 -0
- package/lib/ps/connected-domain.d.mts +3 -0
- package/lib/ps/connected-domain.d.ts +2 -0
- package/lib/ps/connected-domain.js +202 -0
- package/lib/ps/connected-domain.mjs +7 -0
- package/lib/ps/index.cjs +555 -0
- package/lib/ps/index.d.cjs +17 -0
- package/lib/ps/index.d.d.mts +26 -0
- package/lib/ps/index.d.d.ts +26 -0
- package/lib/ps/index.d.mjs +8 -0
- package/lib/ps/index.d.mts +26 -0
- package/lib/ps/index.d.ts +2 -0
- package/lib/ps/index.js +250 -0
- package/lib/ps/index.mjs +203 -0
- package/lib/ps/isWin.cjs +3 -0
- package/lib/ps/isWin.d.mts +3 -0
- package/lib/ps/isWin.d.ts +2 -0
- package/lib/ps/isWin.js +2 -0
- package/lib/ps/isWin.mjs +7 -0
- package/lib/ps/table-parser.cjs +359 -0
- package/lib/ps/table-parser.d.mts +3 -0
- package/lib/ps/table-parser.d.ts +1 -0
- package/lib/ps/table-parser.js +268 -0
- package/lib/ps/table-parser.mjs +8 -0
- package/lib/submodule-install.cjs +118 -0
- package/lib/submodule-install.d.cts +2 -0
- package/lib/submodule-install.d.mts +141 -0
- package/lib/submodule-install.d.ts +141 -0
- package/lib/submodule-install.mjs +116 -0
- package/lib/utils.cjs +35 -0
- package/lib/utils.d.mts +20 -0
- package/lib/utils.d.ts +16 -0
- package/lib/utils.js +42 -28
- package/lib/utils.mjs +7 -0
- package/lib/yarn-reinstall.cjs +42 -0
- package/lib/yarn-reinstall.d.cts +1 -0
- package/lib/yarn-reinstall.d.mts +45 -0
- package/lib/yarn-reinstall.d.ts +45 -0
- package/lib/yarn-reinstall.mjs +50 -0
- package/package.json +80 -38
- package/readme.md +188 -40
- package/src/ps/index.js +285 -0
- package/test/package.json +19 -0
- package/index.js +0 -1
- package/lib/package-resolutions.json +0 -22
package/src/ps/index.js
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
var ChildProcess = require("child_process");
|
|
2
|
+
var IS_WIN = require("./isWin");
|
|
3
|
+
var TableParser = require("./table-parser");
|
|
4
|
+
/**
|
|
5
|
+
* End of line.
|
|
6
|
+
* Basically, the EOL should be:
|
|
7
|
+
* - windows: \r\n
|
|
8
|
+
* - *nix: \n
|
|
9
|
+
* But i'm trying to get every possibilities covered.
|
|
10
|
+
*/
|
|
11
|
+
var EOL = /(\r\n)|(\n\r)|\n|\r/;
|
|
12
|
+
var SystemEOL = require("os").EOL;
|
|
13
|
+
|
|
14
|
+
// ps-node
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Execute child process
|
|
18
|
+
* @type {Function}
|
|
19
|
+
* @param {String[]} args
|
|
20
|
+
* @param {Function} callback
|
|
21
|
+
* @param {Object=null} callback.err
|
|
22
|
+
* @param {Object[]} callback.stdout
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
var Exec =
|
|
26
|
+
(module.exports =
|
|
27
|
+
exports =
|
|
28
|
+
function (args, callback) {
|
|
29
|
+
var spawn = ChildProcess.spawn;
|
|
30
|
+
|
|
31
|
+
// on windows, if use ChildProcess.exec(`wmic process get`), the stdout will gives you nothing
|
|
32
|
+
// that's why I use `cmd` instead
|
|
33
|
+
if (IS_WIN) {
|
|
34
|
+
var CMD = spawn("cmd");
|
|
35
|
+
var stdout = "";
|
|
36
|
+
var stderr = null;
|
|
37
|
+
|
|
38
|
+
CMD.stdout.on("data", function (data) {
|
|
39
|
+
stdout += data.toString();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
CMD.stderr.on("data", function (data) {
|
|
43
|
+
if (stderr === null) {
|
|
44
|
+
stderr = data.toString();
|
|
45
|
+
} else {
|
|
46
|
+
stderr += data.toString();
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
CMD.on("exit", function () {
|
|
51
|
+
var beginRow;
|
|
52
|
+
stdout = stdout.split(EOL);
|
|
53
|
+
|
|
54
|
+
// Find the line index for the titles
|
|
55
|
+
stdout.forEach(function (out, index) {
|
|
56
|
+
if (out && typeof beginRow == "undefined" && out.indexOf("CommandLine") === 0) {
|
|
57
|
+
beginRow = index;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
// get rid of the start (copyright) and the end (current pwd)
|
|
62
|
+
stdout.splice(stdout.length - 1, 1);
|
|
63
|
+
stdout.splice(0, beginRow);
|
|
64
|
+
|
|
65
|
+
callback(stderr, stdout.join(SystemEOL) || false);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
CMD.stdin.write("wmic process get ProcessId,ParentProcessId,CommandLine \n");
|
|
69
|
+
CMD.stdin.end();
|
|
70
|
+
} else {
|
|
71
|
+
if (typeof args === "string") {
|
|
72
|
+
args = args.split(/\s+/);
|
|
73
|
+
}
|
|
74
|
+
const child = spawn("ps", args);
|
|
75
|
+
stdout = "";
|
|
76
|
+
stderr = null;
|
|
77
|
+
|
|
78
|
+
child.stdout.on("data", function (data) {
|
|
79
|
+
stdout += data.toString();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
child.stderr.on("data", function (data) {
|
|
83
|
+
if (stderr === null) {
|
|
84
|
+
stderr = data.toString();
|
|
85
|
+
} else {
|
|
86
|
+
stderr += data.toString();
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
child.on("exit", function () {
|
|
91
|
+
if (stderr) {
|
|
92
|
+
return callback(stderr.toString());
|
|
93
|
+
} else {
|
|
94
|
+
callback(null, stdout || false);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Query Process: Focus on pid & cmd
|
|
102
|
+
* @param query
|
|
103
|
+
* @param {String|String[]} query.pid
|
|
104
|
+
* @param {String} query.command RegExp String
|
|
105
|
+
* @param {String} query.arguments RegExp String
|
|
106
|
+
* @param {String|array} query.psargs
|
|
107
|
+
* @param {Function} callback
|
|
108
|
+
* @param {Object=null} callback.err
|
|
109
|
+
* @param {Object[]} callback.processList
|
|
110
|
+
* @return {Object}
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
exports.lookup = function (query, callback) {
|
|
114
|
+
/**
|
|
115
|
+
* add 'lx' as default ps arguments, since the default ps output in linux like "ubuntu", wont include command arguments
|
|
116
|
+
*/
|
|
117
|
+
var exeArgs = query.psargs || ["lx"];
|
|
118
|
+
var filter = {};
|
|
119
|
+
var idList;
|
|
120
|
+
|
|
121
|
+
// Lookup by PID
|
|
122
|
+
if (query.pid) {
|
|
123
|
+
if (Array.isArray(query.pid)) {
|
|
124
|
+
idList = query.pid;
|
|
125
|
+
} else {
|
|
126
|
+
idList = [query.pid];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Cast all PIDs as Strings
|
|
130
|
+
idList = idList.map(function (v) {
|
|
131
|
+
return String(v);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (query.command) {
|
|
136
|
+
filter["command"] = new RegExp(query.command, "i");
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (query.arguments) {
|
|
140
|
+
filter["arguments"] = new RegExp(query.arguments, "i");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (query.ppid) {
|
|
144
|
+
filter["ppid"] = new RegExp(query.ppid);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return Exec(exeArgs, function (err, output) {
|
|
148
|
+
if (err) {
|
|
149
|
+
return callback(err);
|
|
150
|
+
} else {
|
|
151
|
+
var processList = parseGrid(output);
|
|
152
|
+
var resultList = [];
|
|
153
|
+
|
|
154
|
+
processList.forEach(function (p) {
|
|
155
|
+
var flt;
|
|
156
|
+
var type;
|
|
157
|
+
var result = true;
|
|
158
|
+
|
|
159
|
+
if (idList && idList.indexOf(String(p.pid)) < 0) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
for (type in filter) {
|
|
164
|
+
flt = filter[type];
|
|
165
|
+
result = flt.test(p[type]) ? result : false;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (result) {
|
|
169
|
+
resultList.push(p);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
callback(null, resultList);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Kill process
|
|
180
|
+
* @param pid
|
|
181
|
+
* @param {Object|String} signal
|
|
182
|
+
* @param {String} signal.signal
|
|
183
|
+
* @param {number} signal.timeout
|
|
184
|
+
* @param next
|
|
185
|
+
*/
|
|
186
|
+
|
|
187
|
+
exports.kill = function (pid, signal, next) {
|
|
188
|
+
//opts are optional
|
|
189
|
+
if (arguments.length == 2 && typeof signal == "function") {
|
|
190
|
+
next = signal;
|
|
191
|
+
signal = undefined;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
var checkTimeoutSeconds = (signal && signal.timeout) || 30;
|
|
195
|
+
|
|
196
|
+
if (typeof signal === "object") {
|
|
197
|
+
signal = signal.signal;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
try {
|
|
201
|
+
process.kill(pid, signal);
|
|
202
|
+
} catch (e) {
|
|
203
|
+
return next && next(e);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
var checkConfident = 0;
|
|
207
|
+
var checkTimeoutTimer = null;
|
|
208
|
+
var checkIsTimeout = false;
|
|
209
|
+
|
|
210
|
+
function checkKilled(finishCallback) {
|
|
211
|
+
exports.lookup({ pid: pid }, function (err, list) {
|
|
212
|
+
if (checkIsTimeout) return;
|
|
213
|
+
|
|
214
|
+
if (err) {
|
|
215
|
+
clearTimeout(checkTimeoutTimer);
|
|
216
|
+
finishCallback && finishCallback(err);
|
|
217
|
+
} else if (list.length > 0) {
|
|
218
|
+
checkConfident = checkConfident - 1 || 0;
|
|
219
|
+
checkKilled(finishCallback);
|
|
220
|
+
} else {
|
|
221
|
+
checkConfident++;
|
|
222
|
+
if (checkConfident === 5) {
|
|
223
|
+
clearTimeout(checkTimeoutTimer);
|
|
224
|
+
finishCallback && finishCallback();
|
|
225
|
+
} else {
|
|
226
|
+
checkKilled(finishCallback);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
next && checkKilled(next);
|
|
233
|
+
|
|
234
|
+
checkTimeoutTimer =
|
|
235
|
+
next &&
|
|
236
|
+
setTimeout(function () {
|
|
237
|
+
checkIsTimeout = true;
|
|
238
|
+
next(new Error("Kill process timeout"));
|
|
239
|
+
}, checkTimeoutSeconds * 1000);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Parse the stdout into readable object.
|
|
244
|
+
* @param {String} output
|
|
245
|
+
*/
|
|
246
|
+
|
|
247
|
+
function parseGrid(output) {
|
|
248
|
+
if (!output) {
|
|
249
|
+
return [];
|
|
250
|
+
}
|
|
251
|
+
return formatOutput(TableParser.parse(output));
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* format the structure, extract pid, command, arguments, ppid
|
|
256
|
+
* @param data
|
|
257
|
+
* @return {Array}
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
function formatOutput(data) {
|
|
261
|
+
var formatedData = [];
|
|
262
|
+
data.forEach(function (d) {
|
|
263
|
+
var pid = (d.PID && d.PID[0]) || (d.ProcessId && d.ProcessId[0]) || undefined;
|
|
264
|
+
var cmd = d.CMD || d.CommandLine || d.COMMAND || undefined;
|
|
265
|
+
var ppid = (d.PPID && d.PPID[0]) || (d.ParentProcessId && d.ParentProcessId[0]) || undefined;
|
|
266
|
+
|
|
267
|
+
if (pid && cmd) {
|
|
268
|
+
var command = cmd[0];
|
|
269
|
+
var args = "";
|
|
270
|
+
|
|
271
|
+
if (cmd.length > 1) {
|
|
272
|
+
args = cmd.slice(1);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
formatedData.push({
|
|
276
|
+
pid: pid,
|
|
277
|
+
command: command,
|
|
278
|
+
arguments: args,
|
|
279
|
+
ppid: ppid
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
return formatedData;
|
|
285
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "test",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build:a": "echo a",
|
|
8
|
+
"build:b": "echo b",
|
|
9
|
+
"build:c": "echo c",
|
|
10
|
+
"test": "npm-run-series build:**",
|
|
11
|
+
"install-deps": "npm i -D file:../"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [],
|
|
14
|
+
"author": "",
|
|
15
|
+
"license": "ISC",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"binary-collections": "./.."
|
|
18
|
+
}
|
|
19
|
+
}
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log("binary-collections main script :P");
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"resolutions": {
|
|
3
|
-
"cross-spawn": "https://github.com/dimaslanjaka/node-cross-spawn/raw/private/release/cross-spawn.tgz",
|
|
4
|
-
"safelinkify": "https://github.com/dimaslanjaka/safelink/raw/monorepo/release/safelinkify.tgz",
|
|
5
|
-
"sbg-api": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/sbg-api/release/sbg-api.tgz",
|
|
6
|
-
"sbg-cli": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/sbg-cli/release/sbg-cli.tgz",
|
|
7
|
-
"sbg-server": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/sbg-server/release/sbg-server.tgz",
|
|
8
|
-
"sbg-utility": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/sbg-utility/release/sbg-utility.tgz",
|
|
9
|
-
"sitemap-crawler": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/sitemap-crawler/release/sitemap-crawler.tgz",
|
|
10
|
-
"static-blog-generator": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/static-blog-generator/release/static-blog-generator.tgz",
|
|
11
|
-
"hexo-blogger-xml": "https://github.com/dimaslanjaka/hexo-blogger-xml/raw/monorepo/release/hexo-blogger-xml.tgz",
|
|
12
|
-
"hexo-post-parser": "https://github.com/dimaslanjaka/hexo-post-parser/raw/monorepo/release/hexo-post-parser.tgz",
|
|
13
|
-
"hexo-asset-link": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-asset-link.tgz",
|
|
14
|
-
"hexo-front-matter": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-front-matter.tgz",
|
|
15
|
-
"hexo": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo.tgz",
|
|
16
|
-
"hexo-log": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-log.tgz",
|
|
17
|
-
"hexo-util": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/hexo-util.tgz",
|
|
18
|
-
"warehouse": "https://github.com/dimaslanjaka/hexo/raw/monorepo-v7/releases/warehouse.tgz",
|
|
19
|
-
"git-command-helper": "https://github.com/dimaslanjaka/git-command-helper/raw/monorepo/release/git-command-helper.tgz",
|
|
20
|
-
"instant-indexing": "https://github.com/dimaslanjaka/static-blog-generator/raw/beta/packages/instant-indexing/release/instant-indexing.tgz"
|
|
21
|
-
}
|
|
22
|
-
}
|