fix(testing): use taskkill to kill web server process when running cypress on windows (#27068)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #26599
This commit is contained in:
parent
bb92857b21
commit
c7e1a1681e
@ -1,11 +1,11 @@
|
||||
import { workspaceRoot } from '@nx/devkit';
|
||||
import { dirname, join, relative } from 'path';
|
||||
import { existsSync, lstatSync } from 'fs';
|
||||
import { lstatSync } from 'fs';
|
||||
|
||||
import vitePreprocessor from '../src/plugins/preprocessor-vite';
|
||||
import { NX_PLUGIN_OPTIONS } from '../src/utils/constants';
|
||||
|
||||
import { spawn } from 'child_process';
|
||||
import { execSync, spawn } from 'child_process';
|
||||
import { request as httpRequest } from 'http';
|
||||
import { request as httpsRequest } from 'https';
|
||||
import type { InlineConfig } from 'vite';
|
||||
@ -82,7 +82,13 @@ function startWebServer(webServerCommand: string) {
|
||||
|
||||
return () => {
|
||||
if (process.platform === 'win32') {
|
||||
serverProcess.kill();
|
||||
try {
|
||||
execSync('taskkill /pid ' + serverProcess.pid + ' /T /F');
|
||||
} catch (e) {
|
||||
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// child.kill() does not work on linux
|
||||
// process.kill will kill the whole process group on unix
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user