pubo-node 1.0.144 → 1.0.145
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/dist/pubo-node.js +1 -1
- package/es/child-process/index.js +12 -2
- package/lib/child-process/index.js +115 -329
- package/lib/file-system/index.js +45 -63
- package/lib/ftp-client/index.js +124 -252
- package/lib/grpc/index.js +94 -200
- package/lib/index.js +19 -112
- package/lib/pitch.js +9 -24
- package/lib/ros/topic.js +93 -111
- package/lib/storage/json.js +128 -272
- package/lib/utils/index.js +14 -17
- package/lib/utils/network.js +34 -60
- package/package.json +2 -2
package/lib/utils/network.js
CHANGED
|
@@ -1,66 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
function _async(f) {
|
|
4
|
-
return function () {
|
|
5
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
6
|
-
args[i] = arguments[i];
|
|
7
|
-
}
|
|
8
|
-
try {
|
|
9
|
-
return Promise.resolve(f.apply(this, args));
|
|
10
|
-
} catch (e) {
|
|
11
|
-
return Promise.reject(e);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
var getWifiName = function getWifiName() {
|
|
16
|
-
return _call(getNetworks, function (networks) {
|
|
17
|
-
var wifi = networks.find(function (item) {
|
|
18
|
-
return item.description === 'Wireless interface';
|
|
19
|
-
});
|
|
20
|
-
return wifi ? wifi['logical name'] : '';
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
function _call(body, then, direct) {
|
|
24
|
-
if (direct) {
|
|
25
|
-
return then ? then(body()) : body();
|
|
26
|
-
}
|
|
27
|
-
try {
|
|
28
|
-
var result = Promise.resolve(body());
|
|
29
|
-
return then ? result.then(then) : result;
|
|
30
|
-
} catch (e) {
|
|
31
|
-
return Promise.reject(e);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
var getNetworks = _async(function () {
|
|
35
|
-
return new Promise(function (resolve) {
|
|
36
|
-
var _child$stdout;
|
|
37
|
-
var child = (0, child_process_1.exec)('lshw -C network');
|
|
38
|
-
(_child$stdout = child.stdout) == null ? void 0 : _child$stdout.on('data', function (data) {
|
|
39
|
-
resolve(parseNetworkData(data));
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(exports, "__esModule", {
|
|
44
|
-
value: true
|
|
45
|
-
});
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
3
|
exports.getWifiName = exports.getNetworks = void 0;
|
|
47
|
-
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
48
5
|
function parseNetworkData(data) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
6
|
+
return data
|
|
7
|
+
.toString()
|
|
8
|
+
.replace(/\*-network.*\n/g, '-----')
|
|
9
|
+
.split('-----')
|
|
10
|
+
.filter((item) => item.trim())
|
|
11
|
+
.map((item) => {
|
|
12
|
+
const res = {};
|
|
13
|
+
const tmp = item.split('\n');
|
|
14
|
+
tmp.forEach((i) => {
|
|
15
|
+
const arr = i.split(':').map((key) => key.trim());
|
|
16
|
+
if (arr[0] && arr[1]) {
|
|
17
|
+
res[arr[0]] = arr[1];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return res;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async function getNetworks() {
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
const child = (0, child_process_1.exec)('lshw -C network');
|
|
26
|
+
child.stdout?.on('data', (data) => {
|
|
27
|
+
resolve(parseNetworkData(data));
|
|
28
|
+
});
|
|
61
29
|
});
|
|
62
|
-
return res;
|
|
63
|
-
});
|
|
64
30
|
}
|
|
65
31
|
exports.getNetworks = getNetworks;
|
|
66
|
-
|
|
32
|
+
async function getWifiName() {
|
|
33
|
+
const networks = await getNetworks();
|
|
34
|
+
const wifi = networks.find((item) => item.description === 'Wireless interface');
|
|
35
|
+
if (!wifi) {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
return wifi['logical name'];
|
|
39
|
+
}
|
|
40
|
+
exports.getWifiName = getWifiName;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pubo-node",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.145",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"module": "./es/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"pubo-utils": "^1.0.144",
|
|
25
25
|
"tree-kill": "^1.2.2"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "bed067d4106802ab2a7cd25370d3a2de713bf085",
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@babel/cli": "^7.10.1",
|
|
30
30
|
"@babel/core": "^7.10.2",
|