pingman 1.1.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/builder/builder.js +5 -5
- package/dist/src/builder/linux.d.ts +1 -1
- package/dist/src/builder/linux.js +2 -2
- package/dist/src/builder/mac.d.ts +1 -1
- package/dist/src/builder/mac.js +2 -2
- package/dist/src/builder/windows.d.ts +1 -1
- package/dist/src/builder/windows.js +2 -2
- package/dist/src/errors.js +1 -0
- package/dist/src/helper.js +1 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +24 -8
- package/dist/src/messages.js +1 -0
- package/dist/src/parser/parserFactory.js +1 -1
- package/dist/src/parser/windows.js +1 -1
- package/dist/src/ping.js +1 -1
- package/dist/src/types.d.ts +2 -2
- package/package.json +8 -8
|
@@ -12,18 +12,18 @@ const messages_1 = require("../messages");
|
|
|
12
12
|
//Create instance of builder depending on platform
|
|
13
13
|
function builderFactory(ip, platform, options) {
|
|
14
14
|
let builder;
|
|
15
|
-
helper_1.validateIp(ip);
|
|
16
|
-
if (!helper_1.isPlatformSupported(platform)) {
|
|
15
|
+
(0, helper_1.validateIp)(ip);
|
|
16
|
+
if (!(0, helper_1.isPlatformSupported)(platform)) {
|
|
17
17
|
throw new errors_1.supportedError(messages_1.ERROR_MESSAGES.PLATFORM_NOT_SUPPORTED.replace('platform', platform));
|
|
18
18
|
}
|
|
19
19
|
if (platform === 'win32') {
|
|
20
|
-
builder = windows_1.default(ip, options); //creates and builds commands for windows
|
|
20
|
+
builder = (0, windows_1.default)(ip, options); //creates and builds commands for windows
|
|
21
21
|
}
|
|
22
22
|
else if (platform === 'darwin') {
|
|
23
|
-
builder = mac_1.default(ip, options); //creates and builds commands for mac
|
|
23
|
+
builder = (0, mac_1.default)(ip, options); //creates and builds commands for mac
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
|
-
builder = linux_1.default(ip, options); //creates and builds commands for linux
|
|
26
|
+
builder = (0, linux_1.default)(ip, options); //creates and builds commands for linux
|
|
27
27
|
}
|
|
28
28
|
return builder;
|
|
29
29
|
}
|
|
@@ -27,7 +27,7 @@ const linux = (ip, options) => {
|
|
|
27
27
|
if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
|
|
28
28
|
if (options === null || options === void 0 ? void 0 : options.floodPing) {
|
|
29
29
|
args.push('-f');
|
|
30
|
-
process_1.emitWarning(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning'); //Catch the warning and process it
|
|
30
|
+
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning'); //Catch the warning and process it
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
|
|
@@ -36,7 +36,7 @@ const linux = (ip, options) => {
|
|
|
36
36
|
if (options === null || options === void 0 ? void 0 : options.floodPing) {
|
|
37
37
|
if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
|
|
38
38
|
args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
|
|
39
|
-
process_1.emitWarning(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
|
|
39
|
+
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
42
|
args.push('-f');
|
package/dist/src/builder/mac.js
CHANGED
|
@@ -27,7 +27,7 @@ const mac = (ip, options) => {
|
|
|
27
27
|
if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
|
|
28
28
|
if (options === null || options === void 0 ? void 0 : options.floodPing) {
|
|
29
29
|
args.push('-f');
|
|
30
|
-
process_1.emitWarning(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
|
|
30
|
+
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
33
|
args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
|
|
@@ -39,7 +39,7 @@ const mac = (ip, options) => {
|
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
41
|
args.push('-f');
|
|
42
|
-
process_1.emitWarning(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
|
|
42
|
+
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
if (typeof (options === null || options === void 0 ? void 0 : options.interfaceAddress) === 'string') {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { commandBuilder, extendedPingOptions } from '../types';
|
|
2
|
-
declare const windows: (ip: string, options?: extendedPingOptions
|
|
2
|
+
declare const windows: (ip: string, options?: extendedPingOptions) => commandBuilder;
|
|
3
3
|
export default windows;
|
|
@@ -65,7 +65,7 @@ function checkForIpV4SpecificFields(options) {
|
|
|
65
65
|
optionsUsed = optionsUsed.concat(',', options.hopTimestamp.toString());
|
|
66
66
|
}
|
|
67
67
|
if (optionsUsed.length > 0) {
|
|
68
|
-
process_1.emitWarning(messages_1.ERROR_MESSAGES.ENABLE_IPV4_EXPLICIT.replace('commands', optionsUsed), 'IPV4OnlyWarning');
|
|
68
|
+
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.ENABLE_IPV4_EXPLICIT.replace('commands', optionsUsed), 'IPV4OnlyWarning');
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
return args;
|
|
@@ -85,7 +85,7 @@ function checkForIpV6SpecificFields(options) {
|
|
|
85
85
|
optionsUsed = optionsUsed.concat(',', options.srcAddr);
|
|
86
86
|
}
|
|
87
87
|
if (optionsUsed.length > 0) {
|
|
88
|
-
process_1.emitWarning(messages_1.ERROR_MESSAGES.ENABLE_IPV6_EXPLICIT.replace('commands', optionsUsed), 'IPV6OnlyWarning');
|
|
88
|
+
(0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.ENABLE_IPV6_EXPLICIT.replace('commands', optionsUsed), 'IPV6OnlyWarning');
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
return args;
|
package/dist/src/errors.js
CHANGED
package/dist/src/helper.js
CHANGED
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { extendedPingOptions, pingResponse } from './types';
|
|
2
|
-
declare const ping: (ipAddress: string, pingOptions?: extendedPingOptions
|
|
2
|
+
declare const ping: (ipAddress: string, pingOptions?: extendedPingOptions) => Promise<pingResponse>;
|
|
3
3
|
export default ping;
|
|
4
4
|
export { extendedPingOptions, pingOptions, pingResponse } from './types';
|
package/dist/src/index.js
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
5
18
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
6
19
|
if (mod && mod.__esModule) return mod;
|
|
7
20
|
var result = {};
|
|
8
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result
|
|
9
|
-
result
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
10
23
|
return result;
|
|
11
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
12
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
29
|
const builder_1 = __importDefault(require("./builder/builder"));
|
|
14
30
|
const os = __importStar(require("os"));
|
|
@@ -22,10 +38,10 @@ const ping = async (ipAddress, pingOptions) => {
|
|
|
22
38
|
logger = new log_1.default((pingOptions === null || pingOptions === void 0 ? void 0 : pingOptions.logFilePath) || 'log.txt', (pingOptions === null || pingOptions === void 0 ? void 0 : pingOptions.logToFile) || false);
|
|
23
39
|
try {
|
|
24
40
|
const platform = os.platform();
|
|
25
|
-
const builtCommand = builder_1.default(ipAddress, platform, pingOptions);
|
|
41
|
+
const builtCommand = (0, builder_1.default)(ipAddress, platform, pingOptions);
|
|
26
42
|
logger.writeToLogFile(JSON.stringify(builtCommand));
|
|
27
|
-
const pingOutput = await ping_1.default(builtCommand);
|
|
28
|
-
const parsedOutput = parserFactory_1.default(platform, pingOutput, pingOptions);
|
|
43
|
+
const pingOutput = await (0, ping_1.default)(builtCommand);
|
|
44
|
+
const parsedOutput = (0, parserFactory_1.default)(platform, pingOutput, pingOptions);
|
|
29
45
|
logger.writeToLogFile(JSON.stringify(parsedOutput.output));
|
|
30
46
|
return parsedOutput;
|
|
31
47
|
}
|
package/dist/src/messages.js
CHANGED
|
@@ -13,7 +13,7 @@ const messages_1 = require("../messages");
|
|
|
13
13
|
function parserFactory(platform, output, options) {
|
|
14
14
|
let parser;
|
|
15
15
|
let isWindows = false;
|
|
16
|
-
if (!helper_1.isPlatformSupported(platform)) {
|
|
16
|
+
if (!(0, helper_1.isPlatformSupported)(platform)) {
|
|
17
17
|
throw new errors_1.supportedError(messages_1.ERROR_MESSAGES.PLATFORM_NOT_SUPPORTED.replace('platform', platform));
|
|
18
18
|
}
|
|
19
19
|
if (platform === 'win32') {
|
package/dist/src/ping.js
CHANGED
|
@@ -7,7 +7,7 @@ const execute = async (builtCommand) => {
|
|
|
7
7
|
let output = [];
|
|
8
8
|
return new Promise((resolve, reject) => {
|
|
9
9
|
var _a;
|
|
10
|
-
const ping = child_process_1.spawn(builtCommand.command, builtCommand.arguments);
|
|
10
|
+
const ping = (0, child_process_1.spawn)(builtCommand.command, builtCommand.arguments);
|
|
11
11
|
ping.once("error", () => {
|
|
12
12
|
reject(new errors_1.pingError(messages_1.ERROR_MESSAGES.GENERAL_PING_ERROR.replace("cmd", builtCommand.command).replace("args", builtCommand.arguments.toString())));
|
|
13
13
|
});
|
package/dist/src/types.d.ts
CHANGED
|
@@ -24,11 +24,11 @@ export interface pingOptions {
|
|
|
24
24
|
TTL?: number;
|
|
25
25
|
timeout?: number;
|
|
26
26
|
}
|
|
27
|
-
export
|
|
27
|
+
export type commandBuilder = {
|
|
28
28
|
command: string;
|
|
29
29
|
arguments: string[];
|
|
30
30
|
};
|
|
31
|
-
export
|
|
31
|
+
export type pingResponse = {
|
|
32
32
|
host: string | undefined;
|
|
33
33
|
numericHost: string | undefined;
|
|
34
34
|
alive: boolean | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pingman",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A ping wrapper for node with TypeScript",
|
|
5
5
|
"main": "dist/src",
|
|
6
6
|
"engines": {
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"url": "git://github.com/dopecodez/pingman.git"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@ava/typescript": "^
|
|
26
|
-
"@types/node": "^
|
|
27
|
-
"ava": "^
|
|
25
|
+
"@ava/typescript": "^3.0.1",
|
|
26
|
+
"@types/node": "^18.11.10",
|
|
27
|
+
"ava": "^5.1.0",
|
|
28
28
|
"copyfiles": "^2.2.0",
|
|
29
|
-
"np": "^6.2
|
|
29
|
+
"np": "^7.6.2",
|
|
30
30
|
"nyc": "^15.1.0",
|
|
31
|
-
"typescript": "^
|
|
31
|
+
"typescript": "^4.9.3"
|
|
32
32
|
},
|
|
33
33
|
"files": [
|
|
34
34
|
"dist/src"
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"typescript": {
|
|
45
45
|
"rewritePaths": {
|
|
46
46
|
"test/": "dist/test/"
|
|
47
|
-
}
|
|
47
|
+
},
|
|
48
|
+
"compile": false
|
|
48
49
|
}
|
|
49
50
|
},
|
|
50
|
-
"dependencies": {},
|
|
51
51
|
"keywords": [
|
|
52
52
|
"ping",
|
|
53
53
|
"node-ping",
|