diff --git a/.eslint_dictionary.json b/.eslint_dictionary.json index e249b3861f8..2e0a49ae60c 100644 --- a/.eslint_dictionary.json +++ b/.eslint_dictionary.json @@ -103,6 +103,7 @@ "mysql", "namespace", "namespaces", + "netstat", "nodejs", "nodenext", "nodir", diff --git a/scripts/stop_npm_proxy.ts b/scripts/stop_npm_proxy.ts index 070126177ea..dd8555313db 100644 --- a/scripts/stop_npm_proxy.ts +++ b/scripts/stop_npm_proxy.ts @@ -13,10 +13,20 @@ await execa('npm', ['config', 'set', 'registry', NPM_REGISTRY]); // returns the process id of the process listening on the specified port let pid: number; try { - const lsofResult = await execaCommand( - `lsof -n -t -iTCP:${VERDACCIO_PORT} -sTCP:LISTEN` - ); - pid = Number.parseInt(lsofResult.stdout.toString()); + if (process.platform === 'win32') { + const netStatResult = await execaCommand( + `netstat -n -a -o | grep LISTENING | grep ${VERDACCIO_PORT}`, + { shell: 'bash' } + ); + pid = Number.parseInt( + netStatResult.stdout.toString().split(/(\s)/).slice(-1)[0] + ); + } else { + const lsofResult = await execaCommand( + `lsof -n -t -iTCP:${VERDACCIO_PORT} -sTCP:LISTEN` + ); + pid = Number.parseInt(lsofResult.stdout.toString()); + } } catch (err) { console.warn( 'Could not determine npm proxy process id. Most likely the process has already been stopped.'