sync-dev-server
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { Options, UsedPortAction } from './types'; | ||
@@ -3,0 +2,0 @@ import { ChildProcess } from 'child_process'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.startServer = exports.stopServer = void 0; | ||
exports.stopServer = void 0; | ||
exports.startServer = startServer; | ||
const utils_1 = require("./utils"); | ||
const command_exists_1 = require("command-exists"); | ||
const defaultOptions = { | ||
@@ -28,2 +30,5 @@ port: 5000, | ||
function startServer(command, options = {}) { | ||
if (!(0, command_exists_1.sync)('netstat')) { | ||
throw new Error('Error: the "netstat" command is not in path. Please install net-tools: https://net-tools.sourceforge.io/'); | ||
} | ||
const opts = Object.assign(Object.assign({}, defaultOptions), options); | ||
@@ -42,3 +47,2 @@ const args = command.split(' '); | ||
} | ||
exports.startServer = startServer; | ||
//# sourceMappingURL=dev.js.map |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { startServer, stopServer } from './dev'; | ||
@@ -6,5 +5,5 @@ export { startServer, stopServer }; | ||
startServer: typeof startServer; | ||
stopServer: (server: import("child_process").ChildProcess | null, signal?: string | number) => void; | ||
stopServer: (server: import("child_process").ChildProcess | null, signal?: number | string) => void; | ||
}; | ||
export default _default; | ||
export type { Options, UsedPortAction } from './types'; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { SyncResult } from 'node-netstat'; | ||
@@ -3,0 +2,0 @@ import { Options } from './types'; |
@@ -68,3 +68,13 @@ "use strict"; | ||
} | ||
(0, kill_sync_1.default)(pid, signal, true); | ||
try { | ||
(0, kill_sync_1.default)(pid, signal, true); | ||
} | ||
catch (error) { | ||
console.log(`\ | ||
WARNING - failed to kill server with pid ${pid} using signal ${signal !== null && signal !== void 0 ? signal : 'SIGTERM'}. | ||
ERROR STACK: | ||
${error.stack} | ||
`); | ||
} | ||
}; | ||
@@ -71,0 +81,0 @@ exports.killPid = killPid; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { Options, UsedPortAction } from './types'; | ||
@@ -3,0 +2,0 @@ import { ChildProcess } from 'child_process'; |
import { handleUsedPortErrorOrKill, getNetstat, killPid, createServerSync } from './utils'; | ||
import { sync as commandExistsSync } from 'command-exists'; | ||
const defaultOptions = { | ||
@@ -24,2 +25,5 @@ port: 5000, | ||
export function startServer(command, options = {}) { | ||
if (!commandExistsSync('netstat')) { | ||
throw new Error('Error: the "netstat" command is not in path. Please install net-tools: https://net-tools.sourceforge.io/'); | ||
} | ||
const opts = Object.assign(Object.assign({}, defaultOptions), options); | ||
@@ -26,0 +30,0 @@ const args = command.split(' '); |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { startServer, stopServer } from './dev'; | ||
@@ -6,5 +5,5 @@ export { startServer, stopServer }; | ||
startServer: typeof startServer; | ||
stopServer: (server: import("child_process").ChildProcess | null, signal?: string | number) => void; | ||
stopServer: (server: import("child_process").ChildProcess | null, signal?: number | string) => void; | ||
}; | ||
export default _default; | ||
export type { Options, UsedPortAction } from './types'; |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import { SyncResult } from 'node-netstat'; | ||
@@ -3,0 +2,0 @@ import { Options } from './types'; |
@@ -60,3 +60,13 @@ import netstat from 'node-netstat'; | ||
} | ||
killSync(pid, signal, true); | ||
try { | ||
killSync(pid, signal, true); | ||
} | ||
catch (error) { | ||
console.log(`\ | ||
WARNING - failed to kill server with pid ${pid} using signal ${signal !== null && signal !== void 0 ? signal : 'SIGTERM'}. | ||
ERROR STACK: | ||
${error.stack} | ||
`); | ||
} | ||
}; | ||
@@ -63,0 +73,0 @@ /** |
@@ -10,3 +10,3 @@ { | ||
}, | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"files": [ | ||
@@ -49,20 +49,22 @@ "dist" | ||
"devDependencies": { | ||
"@types/express": "^4.17.20", | ||
"@types/jest": "^29.5.7", | ||
"@types/morgan": "^1.9.7", | ||
"@types/node": "^20.8.10", | ||
"@types/node-netstat": "^1.8.2", | ||
"@typescript-eslint/eslint-plugin": "^6.9.1", | ||
"@typescript-eslint/parser": "^6.9.1", | ||
"eslint": "^8.53.0", | ||
"eslint-plugin-jest": "^27.6.0", | ||
"express": "^4.18.2", | ||
"@types/command-exists": "^1.2.3", | ||
"@types/express": "^4.17.21", | ||
"@types/jest": "^29.5.12", | ||
"@types/morgan": "^1.9.9", | ||
"@types/node": "^20.14.11", | ||
"@types/node-netstat": "^1.8.4", | ||
"@typescript-eslint/eslint-plugin": "^6.21.0", | ||
"@typescript-eslint/parser": "^6.21.0", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-jest": "^27.9.0", | ||
"express": "^4.19.2", | ||
"jest": "^29.7.0", | ||
"morgan": "^1.10.0", | ||
"sync-request-curl": "^2.1.9", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.2.2" | ||
"sync-request-curl": "^2.2.0", | ||
"ts-jest": "^29.2.2", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.5.3" | ||
}, | ||
"dependencies": { | ||
"command-exists": "^1.2.9", | ||
"dns-lookup-sync": "^1.0.0", | ||
@@ -69,0 +71,0 @@ "kill-sync": "^1.0.3", |
@@ -269,2 +269,4 @@ <div align="center"> | ||
**sync-dev-server** has beentested on Linux, Windows and MacOS. It leverages [node-netstat](https://github.com/danielkrainas/node-netstat), [kill-sync](https://github.com/nktnet1/kill-sync), [dns-lookup-sync](https://github.com/nktnet1/dns-lookup-sync) and [slync](https://github.com/nktnet1/slync) which are all cross-platform. | ||
**sync-dev-server** has been tested on Linux, Windows and MacOS. | ||
It leverages [node-netstat](https://github.com/danielkrainas/node-netstat), [kill-sync](https://github.com/nktnet1/kill-sync), [dns-lookup-sync](https://github.com/nktnet1/dns-lookup-sync) and [slync](https://github.com/nktnet1/slync) which are all cross-platform. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
46696
584
271
2
5
17
+ Addedcommand-exists@^1.2.9
+ Addedcommand-exists@1.2.9(transitive)