pingman 2.1.0 → 2.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.
Files changed (38) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +211 -204
  3. package/dist/src/builder/builder.d.ts +3 -3
  4. package/dist/src/builder/builder.js +30 -30
  5. package/dist/src/builder/linux.d.ts +3 -3
  6. package/dist/src/builder/linux.js +82 -82
  7. package/dist/src/builder/mac.d.ts +3 -3
  8. package/dist/src/builder/mac.js +88 -88
  9. package/dist/src/builder/windows.d.ts +3 -3
  10. package/dist/src/builder/windows.js +93 -93
  11. package/dist/src/errors.d.ts +10 -10
  12. package/dist/src/errors.js +25 -25
  13. package/dist/src/helper.d.ts +2 -2
  14. package/dist/src/helper.js +33 -33
  15. package/dist/src/helper.js.map +1 -1
  16. package/dist/src/index.d.ts +4 -4
  17. package/dist/src/index.js +56 -56
  18. package/dist/src/log.d.ts +7 -7
  19. package/dist/src/log.js +25 -25
  20. package/dist/src/messages.d.ts +9 -9
  21. package/dist/src/messages.js +12 -12
  22. package/dist/src/parser/clonePingResponse.d.ts +3 -3
  23. package/dist/src/parser/clonePingResponse.js +20 -20
  24. package/dist/src/parser/linux.d.ts +7 -7
  25. package/dist/src/parser/linux.js +30 -30
  26. package/dist/src/parser/mac.d.ts +11 -11
  27. package/dist/src/parser/mac.js +46 -46
  28. package/dist/src/parser/parser.interface.d.ts +8 -8
  29. package/dist/src/parser/parser.interface.js +2 -2
  30. package/dist/src/parser/parserFactory.d.ts +3 -3
  31. package/dist/src/parser/parserFactory.js +124 -124
  32. package/dist/src/parser/windows.d.ts +13 -13
  33. package/dist/src/parser/windows.js +110 -110
  34. package/dist/src/ping.d.ts +3 -3
  35. package/dist/src/ping.js +22 -22
  36. package/dist/src/types.d.ts +44 -44
  37. package/dist/src/types.js +2 -2
  38. package/package.json +58 -58
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020 Govind S
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Govind S
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,204 +1,211 @@
1
- # PINGMAN [![build](https://github.com/dopecodez/pingman/workflows/build/badge.svg)](https://github.com/dopecodez/pingman/actions) [![Contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dopecodez/pingman/issues) [![npm version](https://badge.fury.io/js/pingman.svg)](https://badge.fury.io/js/pingman) [![Test Coverage](https://codecov.io/github/dopecodez/pingman/graph/badge.svg?token=KRY7AENTQE)](https://codecov.io/github/dopecodez/pingman)
2
-
3
- Human-friendly node wrapper for ping utility across platforms.
4
-
5
- Add ping utility to your projects with zero dependencies. Build with latest ES6 features with native support for async/await and promises.
6
-
7
- Newly released and actively maintained. Small unpacked size.
8
-
9
- # INSTALLATION
10
-
11
- ```
12
- $ npm install pingman
13
- ```
14
-
15
- ## Highlights
16
-
17
- - [Usage](#Usage)
18
- - [Available options](#available-options)
19
- - [Output Model](#output-model)
20
- - [Types](#types)
21
- - [Extended options(Platform-specific)](#extended-options)
22
- - [Contributing](#contributing)
23
-
24
- ## Usage
25
-
26
- ```js
27
- const ping = require('pingman');
28
-
29
- (async () => {
30
- try {
31
- const response = await ping('127.0.0.1');
32
- console.log(response);
33
- if(response.alive){
34
- //=>if pinged ip is available and responds
35
- }
36
- } catch (error) {
37
- console.log(error);
38
- //=> 'Internal server error ...'
39
- }
40
- })();
41
- ```
42
-
43
- ### Usage with options and TypeScript
44
-
45
- ```js
46
- import ping, {pingResponse, pingOptions} from 'pingman'
47
-
48
- (async () => {
49
- try {
50
- const options: pingOptions = {logToFile:true, numberOfEchos: 6, timeout: 2, IPV4: true};
51
- const response: pingResponse = await ping('www.github.com', {logToFile:true, numberOfEchos: 6, timeout: 2, IPV4: true});
52
- console.log(response);
53
- if(response.alive){
54
- //=>if pinged ip is available and responds
55
- }
56
- } catch (error) {
57
- console.log(error);
58
- //=> 'Internal server error ...'
59
- }
60
- })();
61
- ```
62
-
63
- ## Available options
64
-
65
- ```js
66
- let response = await ping(TargetIp, {options})
67
- ```
68
- `TargetIp` can be any valid IPV4 host, IPV6 host or domain name.
69
-
70
- The `options` available are based on the docs available for [Windows](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/ping), and the `man` pages for [Mac](https://ss64.com/osx/ping.html) and [Linux](https://linux.die.net/man/8/ping).
71
-
72
- There are options which are platform-specific across all three platforms. These are included in the `extendedPingOptions` available and can be found [here](#extended-options). The general options available are abstracted across platforms and should work on all platforms. They can be found in the `pingOptions` object available in types.
73
-
74
- | option | Type | On Windows | On Unix |
75
- | :--- | :----: | :--- | :---- |
76
- | numeric | boolean | -a | -n |
77
- | bufferSize | number | -l | -s |
78
- | numberOfEchos | number | -n | -c |
79
- | TTL | number | -i | -t(-m for Mac) |
80
- | timeout | number | -w | -w(-W for Mac) |
81
- | IPV6 | boolean | -6 | ping6 |
82
- | IPV4 | boolean | -4 | ping |
83
-
84
- **Note : The above options are the general options across platforms**
85
-
86
- Please specify the `IPV6` option in case the target is an IPV6 address. While in windows it is not required, it is required in unix systems so as to invoke `ping6` command.
87
-
88
- There are two further options available: `logToFile` and `logFilePath`. If `logToFile` is set to true, it will log the command and output to a default `log.txt` file at your project root. This is helpful in case you are trying to debug or want a more detailed idea of the output. `logFilePath` can be used in case you want a custom log file path relative to your project root.
89
-
90
- ## Output Model
91
-
92
- ```js
93
- /**
94
- * Parsed response
95
- * @typedef {pingResponse} pingResponse
96
- * @param {string} host - The input IP address or HOST
97
- * @param {string} numeric_host - Target IP address
98
- * @param {boolean} alive - True for existed host
99
- * @param {string} output - Raw stdout from system ping
100
- * @param {number} time - Time (float) in ms for first successful ping response
101
- * @param {Array<number>} times - Array of Time (float) in ms for each ping response
102
- * @param {number} min - Minimum time for collection records
103
- * @param {number} max - Maximum time for collection records
104
- * @param {number} avg - Average time for collection records
105
- * @param {number} bufferSize - Buffer size of each packet sent to target
106
- * @param {string} packetLoss - Packet Losses in percent (100% -> "100.000")
107
- * @param {string} number - Standard deviation time for collected records
108
- */
109
- ```
110
-
111
- ## Types
112
-
113
- Pingman exports some handy TypeScript types and interfaces. See the type definition for all the exported types.
114
-
115
- ## Extended options
116
-
117
- **Note : Using the below options could cause your code to behave unexpectedly in some platforms**
118
-
119
- | option | Type | On Windows | On Unix |
120
- | :--- | :----: | :--- | :---- |
121
- | recordRouteHops | number | -r | N/A |
122
- | hopTimestamp | number | -s | N/A |
123
- | interval | number | N/A | -i |
124
- | soDebugOption | boolean | N/A | -d |
125
- | floodPing | boolean | N/A | -f |
126
- | interfaceAddress| string | N/A | -I |
127
- | suppressLoopback| boolean | N/A | -L |
128
- | pattern | string | N/A | -p |
129
- | quiet | boolean | N/A | -q |
130
- | timeBeforeExit | number | N/A | -W(-t for Mac) |
131
- | verboseOutput | boolean | N/A | -v |
132
- | doNotFragment | boolean | -f | -D for Mac |
133
- | srcAddr | string | -S | -S for Mac |
134
-
135
- ## Contributing
136
-
137
- Before opening a pull request please make sure your changes follow the
138
- [contribution guidelines][1].
139
-
140
- [1]: https://github.com/dopecodez/pingman/blob/master/CONTRIBUTING.md
141
-
142
- ## Contributors
143
-
144
- The project would not be the way it is without these rockstars.
145
-
146
- <!-- readme: contributors -start -->
147
- <table>
148
- <tbody>
149
- <tr>
150
- <td align="center">
151
- <a href="https://github.com/dopecodez">
152
- <img src="https://avatars.githubusercontent.com/u/34269105?v=4" width="100;" alt="dopecodez"/>
153
- <br />
154
- <sub><b>Govind S</b></sub>
155
- </a>
156
- </td>
157
- <td align="center">
158
- <a href="https://github.com/Greeshmareji">
159
- <img src="https://avatars.githubusercontent.com/u/57181018?v=4" width="100;" alt="Greeshmareji"/>
160
- <br />
161
- <sub><b>Greeshma R</b></sub>
162
- </a>
163
- </td>
164
- <td align="center">
165
- <a href="https://github.com/luludotdev">
166
- <img src="https://avatars.githubusercontent.com/u/2358182?v=4" width="100;" alt="luludotdev"/>
167
- <br />
168
- <sub><b>Lulu</b></sub>
169
- </a>
170
- </td>
171
- <td align="center">
172
- <a href="https://github.com/JesseVermeulen123">
173
- <img src="https://avatars.githubusercontent.com/u/43927190?v=4" width="100;" alt="JesseVermeulen123"/>
174
- <br />
175
- <sub><b>JessC) Vermeulen</b></sub>
176
- </a>
177
- </td>
178
- <td align="center">
179
- <a href="https://github.com/Sahilhawal">
180
- <img src="https://avatars.githubusercontent.com/u/50511333?v=4" width="100;" alt="Sahilhawal"/>
181
- <br />
182
- <sub><b>Sahil Hawal</b></sub>
183
- </a>
184
- </td>
185
- <td align="center">
186
- <a href="https://github.com/chebro">
187
- <img src="https://avatars.githubusercontent.com/u/54331348?v=4" width="100;" alt="chebro"/>
188
- <br />
189
- <sub><b>Sravanth C.</b></sub>
190
- </a>
191
- </td>
192
- </tr>
193
- <tr>
194
- <td align="center">
195
- <a href="https://github.com/foxxyz">
196
- <img src="https://avatars.githubusercontent.com/u/2602605?v=4" width="100;" alt="foxxyz"/>
197
- <br />
198
- <sub><b>Foxxyz</b></sub>
199
- </a>
200
- </td>
201
- </tr>
202
- <tbody>
203
- </table>
204
- <!-- readme: contributors -end -->
1
+ # PINGMAN [![build](https://github.com/dopecodez/pingman/workflows/build/badge.svg)](https://github.com/dopecodez/pingman/actions) [![Contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dopecodez/pingman/issues) [![npm version](https://badge.fury.io/js/pingman.svg)](https://badge.fury.io/js/pingman) [![Test Coverage](https://codecov.io/github/dopecodez/pingman/graph/badge.svg?token=KRY7AENTQE)](https://codecov.io/github/dopecodez/pingman)
2
+
3
+ Human-friendly node wrapper for ping utility across platforms.
4
+
5
+ Add ping utility to your projects with zero dependencies. Build with latest ES6 features with native support for async/await and promises.
6
+
7
+ Newly released and actively maintained. Small unpacked size.
8
+
9
+ # INSTALLATION
10
+
11
+ ```
12
+ $ npm install pingman
13
+ ```
14
+
15
+ ## Highlights
16
+
17
+ - [Usage](#Usage)
18
+ - [Available options](#available-options)
19
+ - [Output Model](#output-model)
20
+ - [Types](#types)
21
+ - [Extended options(Platform-specific)](#extended-options)
22
+ - [Contributing](#contributing)
23
+
24
+ ## Usage
25
+
26
+ ```js
27
+ const ping = require('pingman');
28
+
29
+ (async () => {
30
+ try {
31
+ const response = await ping('127.0.0.1');
32
+ console.log(response);
33
+ if(response.alive){
34
+ //=>if pinged ip is available and responds
35
+ }
36
+ } catch (error) {
37
+ console.log(error);
38
+ //=> 'Internal server error ...'
39
+ }
40
+ })();
41
+ ```
42
+
43
+ ### Usage with options and TypeScript
44
+
45
+ ```js
46
+ import ping, {pingResponse, pingOptions} from 'pingman'
47
+
48
+ (async () => {
49
+ try {
50
+ const options: pingOptions = {logToFile:true, numberOfEchos: 6, timeout: 2, IPV4: true};
51
+ const response: pingResponse = await ping('www.github.com', {logToFile:true, numberOfEchos: 6, timeout: 2, IPV4: true});
52
+ console.log(response);
53
+ if(response.alive){
54
+ //=>if pinged ip is available and responds
55
+ }
56
+ } catch (error) {
57
+ console.log(error);
58
+ //=> 'Internal server error ...'
59
+ }
60
+ })();
61
+ ```
62
+
63
+ ## Available options
64
+
65
+ ```js
66
+ let response = await ping(TargetIp, {options})
67
+ ```
68
+ `TargetIp` can be any valid IPV4 host, IPV6 host or domain name.
69
+
70
+ The `options` available are based on the docs available for [Windows](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/ping), and the `man` pages for [Mac](https://ss64.com/osx/ping.html) and [Linux](https://linux.die.net/man/8/ping).
71
+
72
+ There are options which are platform-specific across all three platforms. These are included in the `extendedPingOptions` available and can be found [here](#extended-options). The general options available are abstracted across platforms and should work on all platforms. They can be found in the `pingOptions` object available in types.
73
+
74
+ | option | Type | On Windows | On Unix |
75
+ | :--- | :----: | :--- | :---- |
76
+ | numeric | boolean | -a | -n |
77
+ | bufferSize | number | -l | -s |
78
+ | numberOfEchos | number | -n | -c |
79
+ | TTL | number | -i | -t(-m for Mac) |
80
+ | timeout | number | -w | -w(-W for Mac) |
81
+ | IPV6 | boolean | -6 | ping6 |
82
+ | IPV4 | boolean | -4 | ping |
83
+
84
+ **Note : The above options are the general options across platforms**
85
+
86
+ Please specify the `IPV6` option in case the target is an IPV6 address. While in windows it is not required, it is required in unix systems so as to invoke `ping6` command.
87
+
88
+ There are two further options available: `logToFile` and `logFilePath`. If `logToFile` is set to true, it will log the command and output to a default `log.txt` file at your project root. This is helpful in case you are trying to debug or want a more detailed idea of the output. `logFilePath` can be used in case you want a custom log file path relative to your project root.
89
+
90
+ ## Output Model
91
+
92
+ ```js
93
+ /**
94
+ * Parsed response
95
+ * @typedef {pingResponse} pingResponse
96
+ * @param {string} host - The input IP address or HOST
97
+ * @param {string} numeric_host - Target IP address
98
+ * @param {boolean} alive - True for existed host
99
+ * @param {string} output - Raw stdout from system ping
100
+ * @param {number} time - Time (float) in ms for first successful ping response
101
+ * @param {Array<number>} times - Array of Time (float) in ms for each ping response
102
+ * @param {number} min - Minimum time for collection records
103
+ * @param {number} max - Maximum time for collection records
104
+ * @param {number} avg - Average time for collection records
105
+ * @param {number} bufferSize - Buffer size of each packet sent to target
106
+ * @param {string} packetLoss - Packet Losses in percent (100% -> "100.000")
107
+ * @param {string} number - Standard deviation time for collected records
108
+ */
109
+ ```
110
+
111
+ ## Types
112
+
113
+ Pingman exports some handy TypeScript types and interfaces. See the type definition for all the exported types.
114
+
115
+ ## Extended options
116
+
117
+ **Note : Using the below options could cause your code to behave unexpectedly in some platforms**
118
+
119
+ | option | Type | On Windows | On Unix |
120
+ | :--- | :----: | :--- | :---- |
121
+ | recordRouteHops | number | -r | N/A |
122
+ | hopTimestamp | number | -s | N/A |
123
+ | interval | number | N/A | -i |
124
+ | soDebugOption | boolean | N/A | -d |
125
+ | floodPing | boolean | N/A | -f |
126
+ | interfaceAddress| string | N/A | -I |
127
+ | suppressLoopback| boolean | N/A | -L |
128
+ | pattern | string | N/A | -p |
129
+ | quiet | boolean | N/A | -q |
130
+ | timeBeforeExit | number | N/A | -W(-t for Mac) |
131
+ | verboseOutput | boolean | N/A | -v |
132
+ | doNotFragment | boolean | -f | -D for Mac |
133
+ | srcAddr | string | -S | -S for Mac |
134
+
135
+ ## Contributing
136
+
137
+ Before opening a pull request please make sure your changes follow the
138
+ [contribution guidelines][1].
139
+
140
+ [1]: https://github.com/dopecodez/pingman/blob/master/CONTRIBUTING.md
141
+
142
+ ## Contributors
143
+
144
+ The project would not be the way it is without these rockstars.
145
+
146
+ <!-- readme: contributors -start -->
147
+ <table>
148
+ <tbody>
149
+ <tr>
150
+ <td align="center">
151
+ <a href="https://github.com/dopecodez">
152
+ <img src="https://avatars.githubusercontent.com/u/34269105?v=4" width="100;" alt="dopecodez"/>
153
+ <br />
154
+ <sub><b>Govind S</b></sub>
155
+ </a>
156
+ </td>
157
+ <td align="center">
158
+ <a href="https://github.com/lissy93">
159
+ <img src="https://avatars.githubusercontent.com/u/1862727?v=4" width="100;" alt="lissy93"/>
160
+ <br />
161
+ <sub><b>Alicia Sykes</b></sub>
162
+ </a>
163
+ </td>
164
+ <td align="center">
165
+ <a href="https://github.com/Greeshmareji">
166
+ <img src="https://avatars.githubusercontent.com/u/57181018?v=4" width="100;" alt="Greeshmareji"/>
167
+ <br />
168
+ <sub><b>Greeshma R</b></sub>
169
+ </a>
170
+ </td>
171
+ <td align="center">
172
+ <a href="https://github.com/luludotdev">
173
+ <img src="https://avatars.githubusercontent.com/u/2358182?v=4" width="100;" alt="luludotdev"/>
174
+ <br />
175
+ <sub><b>Lulu</b></sub>
176
+ </a>
177
+ </td>
178
+ <td align="center">
179
+ <a href="https://github.com/JesseVermeulen123">
180
+ <img src="https://avatars.githubusercontent.com/u/43927190?v=4" width="100;" alt="JesseVermeulen123"/>
181
+ <br />
182
+ <sub><b>JessC) Vermeulen</b></sub>
183
+ </a>
184
+ </td>
185
+ <td align="center">
186
+ <a href="https://github.com/Sahilhawal">
187
+ <img src="https://avatars.githubusercontent.com/u/50511333?v=4" width="100;" alt="Sahilhawal"/>
188
+ <br />
189
+ <sub><b>Sahil Hawal</b></sub>
190
+ </a>
191
+ </td>
192
+ </tr>
193
+ <tr>
194
+ <td align="center">
195
+ <a href="https://github.com/chebro">
196
+ <img src="https://avatars.githubusercontent.com/u/54331348?v=4" width="100;" alt="chebro"/>
197
+ <br />
198
+ <sub><b>Sravanth C.</b></sub>
199
+ </a>
200
+ </td>
201
+ <td align="center">
202
+ <a href="https://github.com/foxxyz">
203
+ <img src="https://avatars.githubusercontent.com/u/2602605?v=4" width="100;" alt="foxxyz"/>
204
+ <br />
205
+ <sub><b>Foxxyz</b></sub>
206
+ </a>
207
+ </td>
208
+ </tr>
209
+ <tbody>
210
+ </table>
211
+ <!-- readme: contributors -end -->
@@ -1,3 +1,3 @@
1
- import { commandBuilder, extendedPingOptions } from '../types';
2
- declare function builderFactory(ip: string, platform: string, options?: extendedPingOptions): commandBuilder;
3
- export default builderFactory;
1
+ import { commandBuilder, extendedPingOptions } from '../types';
2
+ declare function builderFactory(ip: string, platform: string, options?: extendedPingOptions): commandBuilder;
3
+ export default builderFactory;
@@ -1,31 +1,31 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const helper_1 = require("../helper");
7
- const errors_1 = require("../errors");
8
- const windows_1 = __importDefault(require("./windows"));
9
- const linux_1 = __importDefault(require("./linux"));
10
- const mac_1 = __importDefault(require("./mac"));
11
- const messages_1 = require("../messages");
12
- //Create instance of builder depending on platform
13
- function builderFactory(ip, platform, options) {
14
- let builder;
15
- (0, helper_1.validateIp)(ip);
16
- if (!(0, helper_1.isPlatformSupported)(platform)) {
17
- throw new errors_1.supportedError(messages_1.ERROR_MESSAGES.PLATFORM_NOT_SUPPORTED.replace('platform', platform));
18
- }
19
- if (platform === 'win32') {
20
- builder = (0, windows_1.default)(ip, options); //creates and builds commands for windows
21
- }
22
- else if (platform === 'darwin') {
23
- builder = (0, mac_1.default)(ip, options); //creates and builds commands for mac
24
- }
25
- else {
26
- builder = (0, linux_1.default)(ip, options); //creates and builds commands for linux
27
- }
28
- return builder;
29
- }
30
- exports.default = builderFactory;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const helper_1 = require("../helper");
7
+ const errors_1 = require("../errors");
8
+ const windows_1 = __importDefault(require("./windows"));
9
+ const linux_1 = __importDefault(require("./linux"));
10
+ const mac_1 = __importDefault(require("./mac"));
11
+ const messages_1 = require("../messages");
12
+ //Create instance of builder depending on platform
13
+ function builderFactory(ip, platform, options) {
14
+ let builder;
15
+ (0, helper_1.validateIp)(ip);
16
+ if (!(0, helper_1.isPlatformSupported)(platform)) {
17
+ throw new errors_1.supportedError(messages_1.ERROR_MESSAGES.PLATFORM_NOT_SUPPORTED.replace('platform', platform));
18
+ }
19
+ if (platform === 'win32') {
20
+ builder = (0, windows_1.default)(ip, options); //creates and builds commands for windows
21
+ }
22
+ else if (platform === 'darwin') {
23
+ builder = (0, mac_1.default)(ip, options); //creates and builds commands for mac
24
+ }
25
+ else {
26
+ builder = (0, linux_1.default)(ip, options); //creates and builds commands for linux
27
+ }
28
+ return builder;
29
+ }
30
+ exports.default = builderFactory;
31
31
  //# sourceMappingURL=builder.js.map
@@ -1,3 +1,3 @@
1
- import { commandBuilder, extendedPingOptions } from '../types';
2
- declare const linux: (ip: string, options?: extendedPingOptions) => commandBuilder;
3
- export default linux;
1
+ import { commandBuilder, extendedPingOptions } from '../types';
2
+ declare const linux: (ip: string, options?: extendedPingOptions) => commandBuilder;
3
+ export default linux;