fix(core): repair SIGINT signals on windows (#28496)

using `windowsHide: true` is causing an issue on windows: Ctrl + C
handling isn't enabled and no `SIGINT` is sent to the child process when
users exit the process. See https://github.com/nodejs/node/issues/29837
and https://github.com/nodejs/node-v0.x-archive/issues/5054 for
reference. This will cause leftover processes throughout nx.

This PR sets `windowsHide: false` everywhere except for the plugin
workers and some short-lived utils. They `spawn` child processes but
have explicit handling to make sure they kill themselves when the parent
process dies, so the missing Ctrl + C handling doesn't cause issues.

We will follow up to make sure any other culprits that still cause
windows popups (especially when used through Nx Console) are handled.
Leaving no leftover processes running is more important for now, though.

Keep in mind the underlying tooling (like vite) might have some windows
popups themselves that Nx will inherit.
This commit is contained in:
MaxKless 2024-10-17 21:03:37 +02:00 committed by GitHub
parent 42da5421af
commit 499300fd76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
87 changed files with 179 additions and 173 deletions

View File

@ -273,7 +273,7 @@ export function runCommandUntil(
...opts.env, ...opts.env,
FORCE_COLOR: 'false', FORCE_COLOR: 'false',
}, },
windowsHide: true, windowsHide: false,
}); });
return new Promise((res, rej) => { return new Promise((res, rej) => {
let output = ''; let output = '';

View File

@ -65,7 +65,7 @@ function getPublishedVersion(): Promise<string | undefined> {
exec( exec(
'npm view nx@latest version', 'npm view nx@latest version',
{ {
windowsHide: true, windowsHide: false,
}, },
(error, stdout, stderr) => { (error, stdout, stderr) => {
if (error) { if (error) {

View File

@ -19,7 +19,7 @@ export function spawnAndWait(command: string, args: string[], cwd: string) {
ESLINT_USE_FLAT_CONFIG: process.env.ESLINT_USE_FLAT_CONFIG ?? 'true', ESLINT_USE_FLAT_CONFIG: process.env.ESLINT_USE_FLAT_CONFIG ?? 'true',
}, },
shell: true, shell: true,
windowsHide: true, windowsHide: false,
}); });
childProcess.on('exit', (code) => { childProcess.on('exit', (code) => {
@ -36,7 +36,7 @@ export function execAndWait(command: string, cwd: string) {
return new Promise<{ code: number; stdout: string }>((res, rej) => { return new Promise<{ code: number; stdout: string }>((res, rej) => {
exec( exec(
command, command,
{ cwd, env: { ...process.env, NX_DAEMON: 'false' }, windowsHide: true }, { cwd, env: { ...process.env, NX_DAEMON: 'false' }, windowsHide: false },
(error, stdout, stderr) => { (error, stdout, stderr) => {
if (error) { if (error) {
const logFile = join(cwd, 'error.log'); const logFile = join(cwd, 'error.log');

View File

@ -8,7 +8,7 @@ export function deduceDefaultBase(): string {
const nxDefaultBase = 'main'; const nxDefaultBase = 'main';
try { try {
return ( return (
execSync('git config --get init.defaultBranch', { windowsHide: true }) execSync('git config --get init.defaultBranch', { windowsHide: false })
.toString() .toString()
.trim() || nxDefaultBase .trim() || nxDefaultBase
); );

View File

@ -4,7 +4,7 @@ import { output } from '../output';
export function checkGitVersion(): string | null | undefined { export function checkGitVersion(): string | null | undefined {
try { try {
let gitVersionOutput = execSync('git --version', { windowsHide: true }) let gitVersionOutput = execSync('git --version', { windowsHide: false })
.toString() .toString()
.trim(); .trim();
return gitVersionOutput.match(/[0-9]+\.[0-9]+\.+[0-9]+/)?.[0]; return gitVersionOutput.match(/[0-9]+\.[0-9]+\.+[0-9]+/)?.[0];
@ -43,7 +43,7 @@ export async function initializeGitRepo(
} }
: {}), : {}),
}, },
windowsHide: true, windowsHide: false,
}; };
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
spawn('git', args, spawnOptions).on('close', (code) => { spawn('git', args, spawnOptions).on('close', (code) => {

View File

@ -139,7 +139,7 @@ function shouldRecordStats(): boolean {
try { try {
const stdout = execSync(pmc.getRegistryUrl, { const stdout = execSync(pmc.getRegistryUrl, {
encoding: 'utf-8', encoding: 'utf-8',
windowsHide: true, windowsHide: false,
}); });
const url = new URL(stdout.trim()); const url = new URL(stdout.trim());

View File

@ -9,7 +9,7 @@ export function showNxWarning(workspaceName: string) {
execSync('nx --version', { execSync('nx --version', {
cwd: pathToRunNxCommand, cwd: pathToRunNxCommand,
stdio: ['ignore', 'ignore', 'ignore'], stdio: ['ignore', 'ignore', 'ignore'],
windowsHide: true, windowsHide: false,
}); });
} catch (e) { } catch (e) {
// no nx found // no nx found

View File

@ -123,7 +123,7 @@ export function getPackageManagerVersion(
const version = execSync(`${packageManager} --version`, { const version = execSync(`${packageManager} --version`, {
cwd, cwd,
encoding: 'utf-8', encoding: 'utf-8',
windowsHide: true, windowsHide: false,
}).trim(); }).trim();
pmVersionCache.set(packageManager, version); pmVersionCache.set(packageManager, version);
return version; return version;

View File

@ -78,14 +78,14 @@ function startWebServer(webServerCommand: string) {
// Windows is fine so we leave it attached to this process // Windows is fine so we leave it attached to this process
detached: process.platform !== 'win32', detached: process.platform !== 'win32',
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
}); });
return () => { return () => {
if (process.platform === 'win32') { if (process.platform === 'win32') {
try { try {
execSync('taskkill /pid ' + serverProcess.pid + ' /T /F', { execSync('taskkill /pid ' + serverProcess.pid + ' /T /F', {
windowsHide: true, windowsHide: false,
}); });
} catch (e) { } catch (e) {
if (process.env.NX_VERBOSE_LOGGING === 'true') { if (process.env.NX_VERBOSE_LOGGING === 'true') {

View File

@ -43,7 +43,7 @@ export function installPackagesTask(
const execSyncOptions: ExecSyncOptions = { const execSyncOptions: ExecSyncOptions = {
cwd: join(tree.root, cwd), cwd: join(tree.root, cwd),
stdio: process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit', stdio: process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit',
windowsHide: true, windowsHide: false,
}; };
// ensure local registry from process is not interfering with the install // ensure local registry from process is not interfering with the install
// when we start the process from temp folder the local registry would override the custom registry // when we start the process from temp folder the local registry would override the custom registry

View File

@ -497,7 +497,7 @@ export function ensurePackage<T extends any = any>(
execSync(preInstallCommand, { execSync(preInstallCommand, {
cwd: tempDir, cwd: tempDir,
stdio: isVerbose ? 'inherit' : 'ignore', stdio: isVerbose ? 'inherit' : 'ignore',
windowsHide: true, windowsHide: false,
}); });
} }
let addCommand = getPackageManagerCommand(packageManager).addDev; let addCommand = getPackageManagerCommand(packageManager).addDev;
@ -508,7 +508,7 @@ export function ensurePackage<T extends any = any>(
execSync(`${addCommand} ${pkg}@${requiredVersion}`, { execSync(`${addCommand} ${pkg}@${requiredVersion}`, {
cwd: tempDir, cwd: tempDir,
stdio: isVerbose ? 'inherit' : 'ignore', stdio: isVerbose ? 'inherit' : 'ignore',
windowsHide: true, windowsHide: false,
}); });
addToNodePath(join(workspaceRoot, 'node_modules')); addToNodePath(join(workspaceRoot, 'node_modules'));

View File

@ -68,7 +68,7 @@ export function podInstall(
execSync('touch .xcode.env', { execSync('touch .xcode.env', {
cwd: iosDirectory, cwd: iosDirectory,
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
}); });
} }
execSync( execSync(
@ -78,7 +78,7 @@ export function podInstall(
{ {
cwd: iosDirectory, cwd: iosDirectory,
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
} }
); );
} catch (e) { } catch (e) {

View File

@ -11,13 +11,13 @@ export function resolveEas(workspaceRoot: string): string {
let npmGlobalPath: string, yarnGlobalPath: string; let npmGlobalPath: string, yarnGlobalPath: string;
try { try {
npmGlobalPath = execSync('npm root -g', { windowsHide: true }) npmGlobalPath = execSync('npm root -g', { windowsHide: false })
?.toString() ?.toString()
?.trim() ?.trim()
?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes ?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes
} catch {} } catch {}
try { try {
yarnGlobalPath = execSync('yarn global dir', { windowsHide: true }) yarnGlobalPath = execSync('yarn global dir', { windowsHide: false })
?.toString() ?.toString()
?.trim() ?.trim()
?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes ?.replace('\u001b[2K\u001b[1G', ''); // strip out ansi codes

View File

@ -21,7 +21,7 @@ export async function killTree(pid: number, signal: NodeJS.Signals) {
exec( exec(
'taskkill /pid ' + pid + ' /T /F', 'taskkill /pid ' + pid + ' /T /F',
{ {
windowsHide: true, windowsHide: false,
}, },
(error) => { (error) => {
// Ignore Fatal errors (128) because it might be due to the process already being killed. // Ignore Fatal errors (128) because it might be due to the process already being killed.
@ -37,7 +37,7 @@ export async function killTree(pid: number, signal: NodeJS.Signals) {
pidsToProcess, pidsToProcess,
function (parentPid) { function (parentPid) {
return spawn('pgrep', ['-P', parentPid], { return spawn('pgrep', ['-P', parentPid], {
windowsHide: true, windowsHide: false,
}); });
}, },
function () { function () {
@ -55,7 +55,7 @@ export async function killTree(pid: number, signal: NodeJS.Signals) {
'ps', 'ps',
['-o', 'pid', '--no-headers', '--ppid', parentPid], ['-o', 'pid', '--no-headers', '--ppid', parentPid],
{ {
windowsHide: true, windowsHide: false,
} }
); );
}, },

View File

@ -128,7 +128,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
env: processEnv(true), env: processEnv(true),
cwd: context.root, cwd: context.root,
stdio: ['ignore', 'pipe', 'pipe'], stdio: ['ignore', 'pipe', 'pipe'],
windowsHide: true, windowsHide: false,
}); });
const resultJson = JSON.parse(result.toString()); const resultJson = JSON.parse(result.toString());
@ -154,7 +154,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
env: processEnv(true), env: processEnv(true),
cwd: context.root, cwd: context.root,
stdio: 'ignore', stdio: 'ignore',
windowsHide: true, windowsHide: false,
}); });
console.log( console.log(
`Added the dist-tag ${tag} to v${currentVersion} for registry ${registry}.\n` `Added the dist-tag ${tag} to v${currentVersion} for registry ${registry}.\n`
@ -269,7 +269,7 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
env: processEnv(true), env: processEnv(true),
cwd: context.root, cwd: context.root,
stdio: ['ignore', 'pipe', 'pipe'], stdio: ['ignore', 'pipe', 'pipe'],
windowsHide: true, windowsHide: false,
}); });
/** /**

View File

@ -136,7 +136,7 @@ function createVerdaccioOptions(
function setupNpm(options: VerdaccioExecutorSchema) { function setupNpm(options: VerdaccioExecutorSchema) {
try { try {
execSync('npm --version', { env, windowsHide: true }); execSync('npm --version', { env, windowsHide: false });
} catch (e) { } catch (e) {
return () => {}; return () => {};
} }
@ -151,7 +151,7 @@ function setupNpm(options: VerdaccioExecutorSchema) {
npmRegistryPaths.push( npmRegistryPaths.push(
execSync( execSync(
`npm config get ${registryName} --location ${options.location}`, `npm config get ${registryName} --location ${options.location}`,
{ env, windowsHide: true } { env, windowsHide: false }
) )
?.toString() ?.toString()
?.trim() ?.trim()
@ -159,12 +159,12 @@ function setupNpm(options: VerdaccioExecutorSchema) {
); );
execSync( execSync(
`npm config set ${registryName} http://localhost:${options.port}/ --location ${options.location}`, `npm config set ${registryName} http://localhost:${options.port}/ --location ${options.location}`,
{ env, windowsHide: true } { env, windowsHide: false }
); );
execSync( execSync(
`npm config set //localhost:${options.port}/:_authToken="secretVerdaccioToken" --location ${options.location}`, `npm config set //localhost:${options.port}/:_authToken="secretVerdaccioToken" --location ${options.location}`,
{ env, windowsHide: true } { env, windowsHide: false }
); );
logger.info( logger.info(
@ -181,7 +181,7 @@ function setupNpm(options: VerdaccioExecutorSchema) {
try { try {
const currentNpmRegistryPath = execSync( const currentNpmRegistryPath = execSync(
`npm config get registry --location ${options.location}`, `npm config get registry --location ${options.location}`,
{ env, windowsHide: true } { env, windowsHide: false }
) )
?.toString() ?.toString()
?.trim() ?.trim()
@ -194,7 +194,7 @@ function setupNpm(options: VerdaccioExecutorSchema) {
) { ) {
execSync( execSync(
`npm config set ${registryName} ${npmRegistryPaths[index]} --location ${options.location}`, `npm config set ${registryName} ${npmRegistryPaths[index]} --location ${options.location}`,
{ env, windowsHide: true } { env, windowsHide: false }
); );
logger.info( logger.info(
`Reset npm ${registryName} to ${npmRegistryPaths[index]}` `Reset npm ${registryName} to ${npmRegistryPaths[index]}`
@ -204,7 +204,7 @@ function setupNpm(options: VerdaccioExecutorSchema) {
`npm config delete ${registryName} --location ${options.location}`, `npm config delete ${registryName} --location ${options.location}`,
{ {
env, env,
windowsHide: true, windowsHide: false,
} }
); );
logger.info('Cleared custom npm registry'); logger.info('Cleared custom npm registry');
@ -212,7 +212,7 @@ function setupNpm(options: VerdaccioExecutorSchema) {
}); });
execSync( execSync(
`npm config delete //localhost:${options.port}/:_authToken --location ${options.location}`, `npm config delete //localhost:${options.port}/:_authToken --location ${options.location}`,
{ env, windowsHide: true } { env, windowsHide: false }
); );
} catch (e) { } catch (e) {
throw new Error(`Failed to reset npm registry: ${e.message}`); throw new Error(`Failed to reset npm registry: ${e.message}`);
@ -231,7 +231,7 @@ function getYarnUnsafeHttpWhitelist(isYarnV1: boolean) {
JSON.parse( JSON.parse(
execSync(`yarn config get unsafeHttpWhitelist --json`, { execSync(`yarn config get unsafeHttpWhitelist --json`, {
env, env,
windowsHide: true, windowsHide: false,
}).toString() }).toString()
) )
) )
@ -247,13 +247,13 @@ function setYarnUnsafeHttpWhitelist(
`yarn config set unsafeHttpWhitelist --json '${JSON.stringify( `yarn config set unsafeHttpWhitelist --json '${JSON.stringify(
Array.from(currentWhitelist) Array.from(currentWhitelist)
)}'` + (options.location === 'user' ? ' --home' : ''), )}'` + (options.location === 'user' ? ' --home' : ''),
{ env, windowsHide: true } { env, windowsHide: false }
); );
} else { } else {
execSync( execSync(
`yarn config unset unsafeHttpWhitelist` + `yarn config unset unsafeHttpWhitelist` +
(options.location === 'user' ? ' --home' : ''), (options.location === 'user' ? ' --home' : ''),
{ env, windowsHide: true } { env, windowsHide: false }
); );
} }
} }
@ -266,7 +266,9 @@ function setupYarn(options: VerdaccioExecutorSchema) {
try { try {
isYarnV1 = isYarnV1 =
major( major(
execSync('yarn --version', { env, windowsHide: true }).toString().trim() execSync('yarn --version', { env, windowsHide: false })
.toString()
.trim()
) === 1; ) === 1;
} catch { } catch {
// This would fail if yarn is not installed which is okay // This would fail if yarn is not installed which is okay
@ -281,7 +283,7 @@ function setupYarn(options: VerdaccioExecutorSchema) {
yarnRegistryPaths.push( yarnRegistryPaths.push(
execSync(`yarn config get ${scopeName}${registryConfigName}`, { execSync(`yarn config get ${scopeName}${registryConfigName}`, {
env, env,
windowsHide: true, windowsHide: false,
}) })
?.toString() ?.toString()
?.trim() ?.trim()
@ -291,7 +293,7 @@ function setupYarn(options: VerdaccioExecutorSchema) {
execSync( execSync(
`yarn config set ${scopeName}${registryConfigName} http://localhost:${options.port}/` + `yarn config set ${scopeName}${registryConfigName} http://localhost:${options.port}/` +
(options.location === 'user' ? ' --home' : ''), (options.location === 'user' ? ' --home' : ''),
{ env, windowsHide: true } { env, windowsHide: false }
); );
logger.info( logger.info(
@ -318,7 +320,7 @@ function setupYarn(options: VerdaccioExecutorSchema) {
try { try {
const currentYarnRegistryPath = execSync( const currentYarnRegistryPath = execSync(
`yarn config get ${registryConfigName}`, `yarn config get ${registryConfigName}`,
{ env, windowsHide: true } { env, windowsHide: false }
) )
?.toString() ?.toString()
?.trim() ?.trim()
@ -339,7 +341,7 @@ function setupYarn(options: VerdaccioExecutorSchema) {
{ {
env, env,
windowsHide: true, windowsHide: false,
} }
); );
logger.info( logger.info(
@ -349,7 +351,7 @@ function setupYarn(options: VerdaccioExecutorSchema) {
execSync( execSync(
`yarn config ${isYarnV1 ? 'delete' : 'unset'} ${registryName}` + `yarn config ${isYarnV1 ? 'delete' : 'unset'} ${registryName}` +
(options.location === 'user' ? ' --home' : ''), (options.location === 'user' ? ' --home' : ''),
{ env, windowsHide: true } { env, windowsHide: false }
); );
logger.info(`Cleared custom yarn ${registryConfigName}`); logger.info(`Cleared custom yarn ${registryConfigName}`);
} }

View File

@ -213,7 +213,7 @@ To fix this you will either need to add a package.json file at that location, or
exec( exec(
`npm view ${packageName} version --"${registryConfigKey}=${registry}" --tag=${tag}`, `npm view ${packageName} version --"${registryConfigKey}=${registry}" --tag=${tag}`,
{ {
windowsHide: true, windowsHide: false,
}, },
(error, stdout, stderr) => { (error, stdout, stderr) => {
if (error) { if (error) {

View File

@ -133,7 +133,7 @@ function execLockFileUpdate(
...process.env, ...process.env,
...env, ...env,
}, },
windowsHide: true, windowsHide: false,
}); });
} catch (e) { } catch (e) {
output.error({ output.error({

View File

@ -23,7 +23,7 @@ export async function setupVerdaccio(
generateFiles(tree, path.join(__dirname, 'files'), '.verdaccio', { generateFiles(tree, path.join(__dirname, 'files'), '.verdaccio', {
npmUplinkRegistry: npmUplinkRegistry:
execSync('npm config get registry', { execSync('npm config get registry', {
windowsHide: true, windowsHide: false,
}) })
?.toString() ?.toString()
?.trim() ?? 'https://registry.npmjs.org', ?.trim() ?? 'https://registry.npmjs.org',

View File

@ -48,7 +48,7 @@ export function startLocalRegistry({
execSync( execSync(
`npm config set //localhost:${port}/:_authToken "secretVerdaccioToken"`, `npm config set //localhost:${port}/:_authToken "secretVerdaccioToken"`,
{ {
windowsHide: true, windowsHide: false,
} }
); );
@ -63,7 +63,7 @@ export function startLocalRegistry({
resolve(() => { resolve(() => {
childProcess.kill(); childProcess.kill();
execSync(`npm config delete //localhost:${port}/:_authToken`, { execSync(`npm config delete //localhost:${port}/:_authToken`, {
windowsHide: true, windowsHide: false,
}); });
}); });
childProcess?.stdout?.off('data', listener); childProcess?.stdout?.off('data', listener);

View File

@ -108,7 +108,7 @@ async function getNpmConfigValue(key: string, cwd: string): Promise<string> {
async function execAsync(command: string, cwd: string): Promise<string> { async function execAsync(command: string, cwd: string): Promise<string> {
// Must be non-blocking async to allow spinner to render // Must be non-blocking async to allow spinner to render
return new Promise<string>((resolve, reject) => { return new Promise<string>((resolve, reject) => {
exec(command, { cwd, windowsHide: true }, (error, stdout, stderr) => { exec(command, { cwd, windowsHide: false }, (error, stdout, stderr) => {
if (error) { if (error) {
return reject(error); return reject(error);
} }

View File

@ -85,7 +85,7 @@ export async function compileSwc(
const swcCmdLog = execSync(getSwcCmd(normalizedOptions), { const swcCmdLog = execSync(getSwcCmd(normalizedOptions), {
encoding: 'utf8', encoding: 'utf8',
cwd: normalizedOptions.swcCliOptions.swcCwd, cwd: normalizedOptions.swcCliOptions.swcCwd,
windowsHide: true, windowsHide: false,
}); });
logger.log(swcCmdLog.replace(/\n/, '')); logger.log(swcCmdLog.replace(/\n/, ''));
const isCompileSuccess = swcCmdLog.includes('Successfully compiled'); const isCompileSuccess = swcCmdLog.includes('Successfully compiled');
@ -138,7 +138,7 @@ export async function* compileSwcWatch(
const swcWatcher = exec(getSwcCmd(normalizedOptions, true), { const swcWatcher = exec(getSwcCmd(normalizedOptions, true), {
cwd: normalizedOptions.swcCliOptions.swcCwd, cwd: normalizedOptions.swcCliOptions.swcCwd,
windowsHide: true, windowsHide: false,
}); });
processOnExit = () => { processOnExit = () => {

View File

@ -159,7 +159,7 @@ export async function applicationGenerator(tree: Tree, schema: Schema) {
execSync(`npx -y nuxi prepare`, { execSync(`npx -y nuxi prepare`, {
cwd: options.appProjectRoot, cwd: options.appProjectRoot,
windowsHide: true, windowsHide: false,
}); });
} catch (e) { } catch (e) {
console.error( console.error(

View File

@ -252,14 +252,14 @@ function getLocalNxVersion(workspace: WorkspaceTypeAndRoot): string | null {
function _getLatestVersionOfNx(): string { function _getLatestVersionOfNx(): string {
try { try {
return execSync('npm view nx@latest version', { return execSync('npm view nx@latest version', {
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim(); .trim();
} catch { } catch {
try { try {
return execSync('pnpm view nx@latest version', { return execSync('pnpm view nx@latest version', {
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim(); .trim();

View File

@ -26,7 +26,7 @@ async function requirePowerpack(): Promise<any> {
execSync( execSync(
`${getPackageManagerCommand().addDev} @nx/powerpack-license@latest`, `${getPackageManagerCommand().addDev} @nx/powerpack-license@latest`,
{ {
windowsHide: true, windowsHide: false,
} }
); );

View File

@ -46,7 +46,7 @@ async function installPackage(
exec( exec(
`${pmc.addDev} ${pkgName}@${version}`, `${pmc.addDev} ${pkgName}@${version}`,
{ {
windowsHide: true, windowsHide: false,
}, },
(error, stdout) => { (error, stdout) => {
if (error) { if (error) {

View File

@ -50,7 +50,7 @@ export async function viewLogs(): Promise<number> {
const pmc = getPackageManagerCommand(); const pmc = getPackageManagerCommand();
execSync(`${pmc.exec} nx-cloud upload-and-show-run-details`, { execSync(`${pmc.exec} nx-cloud upload-and-show-run-details`, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
windowsHide: true, windowsHide: false,
}); });
if (!cloudUsed) { if (!cloudUsed) {

View File

@ -54,7 +54,7 @@ export async function nxExecCommand(
NX_PROJECT_ROOT_PATH: NX_PROJECT_ROOT_PATH:
projectGraph.nodes?.[process.env.NX_TASK_TARGET_PROJECT]?.data?.root, projectGraph.nodes?.[process.env.NX_TASK_TARGET_PROJECT]?.data?.root,
}, },
windowsHide: true, windowsHide: false,
}); });
} else { } else {
// nx exec is being ran inside of Nx's context // nx exec is being ran inside of Nx's context
@ -105,7 +105,7 @@ async function runScriptAsNxTarget(
projectGraph.nodes?.[projectName]?.data?.root projectGraph.nodes?.[projectName]?.data?.root
) )
: workspaceRoot, : workspaceRoot,
windowsHide: true, windowsHide: false,
}); });
}); });
} }
@ -132,7 +132,7 @@ function runTargetOnProject(
execSync(command, { execSync(command, {
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
}); });
} }

View File

@ -211,7 +211,7 @@ function write(patterns: string[]) {
)}`, )}`,
{ {
stdio: [0, 1, 2], stdio: [0, 1, 2],
windowsHide: true, windowsHide: false,
} }
); );
@ -222,7 +222,7 @@ function write(patterns: string[]) {
)} --parser json`, )} --parser json`,
{ {
stdio: [0, 1, 2], stdio: [0, 1, 2],
windowsHide: true, windowsHide: false,
} }
); );
} }
@ -239,7 +239,7 @@ async function check(patterns: string[]): Promise<string[]> {
return new Promise((resolve) => { return new Promise((resolve) => {
exec( exec(
`node "${prettierPath}" --list-different ${patterns.join(' ')}`, `node "${prettierPath}" --list-different ${patterns.join(' ')}`,
{ encoding: 'utf-8', windowsHide: true }, { encoding: 'utf-8', windowsHide: false },
(error, stdout) => { (error, stdout) => {
if (error) { if (error) {
// The command failed so there are files with different formatting. Prettier writes them to stdout, newline separated. // The command failed so there are files with different formatting. Prettier writes them to stdout, newline separated.

View File

@ -1270,6 +1270,6 @@ function getHelpTextFromTarget(
return execSync(command, { return execSync(command, {
cwd: target.options?.cwd ?? workspaceRoot, cwd: target.options?.cwd ?? workspaceRoot,
windowsHide: true, windowsHide: false,
}).toString(); }).toString();
} }

View File

@ -6,6 +6,6 @@ export function setupIntegratedWorkspace(): void {
execSync(`${pmc.exec} nx g @nx/angular:ng-add`, { execSync(`${pmc.exec} nx g @nx/angular:ng-add`, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
windowsHide: true, windowsHide: false,
}); });
} }

View File

@ -108,7 +108,7 @@ export async function getLegacyMigrationFunctionIfApplicable(
output.log({ title: '📝 Setting up workspace' }); output.log({ title: '📝 Setting up workspace' });
execSync(`${pmc.exec} ${legacyMigrationCommand}`, { execSync(`${pmc.exec} ${legacyMigrationCommand}`, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
windowsHide: true, windowsHide: false,
}); });
if (useNxCloud) { if (useNxCloud) {
@ -149,7 +149,7 @@ async function installDependencies(
} }
writeJsonFile(`package.json`, json); writeJsonFile(`package.json`, json);
execSync(pmc.install, { stdio: [0, 1, 2], windowsHide: true }); execSync(pmc.install, { stdio: [0, 1, 2], windowsHide: false });
} }
async function resolvePackageVersion( async function resolvePackageVersion(

View File

@ -68,7 +68,7 @@ export function generateDotNxSetup(version?: string) {
export function normalizeVersionForNxJson(pkg: string, version: string) { export function normalizeVersionForNxJson(pkg: string, version: string) {
if (!valid(version)) { if (!valid(version)) {
version = execSync(`npm view ${pkg}@${version} version`, { version = execSync(`npm view ${pkg}@${version} version`, {
windowsHide: true, windowsHide: false,
}).toString(); }).toString();
} }
return version.trimEnd(); return version.trimEnd();

View File

@ -90,7 +90,7 @@ function performInstallation(
cp.execSync('npm i', { cp.execSync('npm i', {
cwd: path.dirname(installationPath), cwd: path.dirname(installationPath),
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
}); });
} catch (e) { } catch (e) {
// revert possible changes to the current installation // revert possible changes to the current installation

View File

@ -2,7 +2,7 @@ import { execSync } from 'child_process';
export function checkForUncommittedChanges() { export function checkForUncommittedChanges() {
const gitResult = execSync('git status --porcelain', { const gitResult = execSync('git status --porcelain', {
windowsHide: true, windowsHide: false,
}).toString(); }).toString();
const filteredResults = gitResult const filteredResults = gitResult

View File

@ -70,7 +70,7 @@ function installDependencies(options: NormalizedOptions) {
execSync(`${options.pmc.addDev} ${dependencies.join(' ')}`, { execSync(`${options.pmc.addDev} ${dependencies.join(' ')}`, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
windowsHide: true, windowsHide: false,
}); });
} }
@ -88,7 +88,7 @@ async function normalizeOptions(options: Options): Promise<NormalizedOptions> {
}; };
const isCRA5 = /^[^~]?5/.test(deps['react-scripts']); const isCRA5 = /^[^~]?5/.test(deps['react-scripts']);
const npmVersion = execSync('npm -v', { const npmVersion = execSync('npm -v', {
windowsHide: true, windowsHide: false,
}).toString(); }).toString();
// Should remove this check 04/2023 once Node 14 & npm 6 reach EOL // Should remove this check 04/2023 once Node 14 & npm 6 reach EOL
const npxYesFlagNeeded = !npmVersion.startsWith('6'); // npm 7 added -y flag to npx const npxYesFlagNeeded = !npmVersion.startsWith('6'); // npm 7 added -y flag to npx
@ -131,11 +131,11 @@ async function reorgnizeWorkspaceStructure(options: NormalizedOptions) {
execSync(`echo "node_modules" >> .gitignore`, { execSync(`echo "node_modules" >> .gitignore`, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
windowsHide: true, windowsHide: false,
}); });
execSync(`echo "dist" >> .gitignore`, { execSync(`echo "dist" >> .gitignore`, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
windowsHide: true, windowsHide: false,
}); });
process.chdir('..'); process.chdir('..');
@ -177,7 +177,7 @@ function createTempWorkspace(options: NormalizedOptions) {
} ${ } ${
options.addE2e ? '--e2eTestRunner=playwright' : '--e2eTestRunner=none' options.addE2e ? '--e2eTestRunner=playwright' : '--e2eTestRunner=none'
}`, }`,
{ stdio: [0, 1, 2], windowsHide: true } { stdio: [0, 1, 2], windowsHide: false }
); );
output.log({ title: '👋 Welcome to Nx!' }); output.log({ title: '👋 Welcome to Nx!' });
@ -330,7 +330,7 @@ async function addBundler(options: NormalizedOptions) {
execSync(`echo "SKIP_PREFLIGHT_CHECK=true" > .env`, { execSync(`echo "SKIP_PREFLIGHT_CHECK=true" > .env`, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
windowsHide: true, windowsHide: false,
}); });
} }
} }

View File

@ -68,28 +68,28 @@ function deduceDefaultBase() {
try { try {
execSync(`git rev-parse --verify main`, { execSync(`git rev-parse --verify main`, {
stdio: ['ignore', 'ignore', 'ignore'], stdio: ['ignore', 'ignore', 'ignore'],
windowsHide: true, windowsHide: false,
}); });
return 'main'; return 'main';
} catch { } catch {
try { try {
execSync(`git rev-parse --verify dev`, { execSync(`git rev-parse --verify dev`, {
stdio: ['ignore', 'ignore', 'ignore'], stdio: ['ignore', 'ignore', 'ignore'],
windowsHide: true, windowsHide: false,
}); });
return 'dev'; return 'dev';
} catch { } catch {
try { try {
execSync(`git rev-parse --verify develop`, { execSync(`git rev-parse --verify develop`, {
stdio: ['ignore', 'ignore', 'ignore'], stdio: ['ignore', 'ignore', 'ignore'],
windowsHide: true, windowsHide: false,
}); });
return 'develop'; return 'develop';
} catch { } catch {
try { try {
execSync(`git rev-parse --verify next`, { execSync(`git rev-parse --verify next`, {
stdio: ['ignore', 'ignore', 'ignore'], stdio: ['ignore', 'ignore', 'ignore'],
windowsHide: true, windowsHide: false,
}); });
return 'next'; return 'next';
} catch { } catch {
@ -144,7 +144,11 @@ export function runInstall(
repoRoot: string, repoRoot: string,
pmc: PackageManagerCommands = getPackageManagerCommand() pmc: PackageManagerCommands = getPackageManagerCommand()
) { ) {
execSync(pmc.install, { stdio: [0, 1, 2], cwd: repoRoot, windowsHide: true }); execSync(pmc.install, {
stdio: [0, 1, 2],
cwd: repoRoot,
windowsHide: false,
});
} }
export async function initCloud( export async function initCloud(

View File

@ -95,7 +95,7 @@ export async function initHandler(options: InitArgs) {
} else { } else {
execSync(`npx --yes create-nx-workspace@${version} ${args}`, { execSync(`npx --yes create-nx-workspace@${version} ${args}`, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
windowsHide: true, windowsHide: false,
}); });
} }
} }

View File

@ -59,7 +59,7 @@ export function installPlugins(
{ {
stdio: [0, 1, 2], stdio: [0, 1, 2],
cwd: repoRoot, cwd: repoRoot,
windowsHide: true, windowsHide: false,
} }
); );
} }

View File

@ -128,7 +128,7 @@ function runMigration() {
} }
execSync(`${p} _migrate ${process.argv.slice(3).join(' ')}`, { execSync(`${p} _migrate ${process.argv.slice(3).join(' ')}`, {
stdio: ['inherit', 'inherit', 'inherit'], stdio: ['inherit', 'inherit', 'inherit'],
windowsHide: true, windowsHide: false,
}); });
} }
} else { } else {
@ -156,14 +156,14 @@ function nxCliPath() {
execSync(pmc.preInstall, { execSync(pmc.preInstall, {
cwd: tmpDir, cwd: tmpDir,
stdio: ['ignore', 'ignore', 'ignore'], stdio: ['ignore', 'ignore', 'ignore'],
windowsHide: true, windowsHide: false,
}); });
// if it's berry ensure we set the node_linker to node-modules // if it's berry ensure we set the node_linker to node-modules
if (packageManager === 'yarn' && pmc.ciInstall.includes('immutable')) { if (packageManager === 'yarn' && pmc.ciInstall.includes('immutable')) {
execSync('yarn config set nodeLinker node-modules', { execSync('yarn config set nodeLinker node-modules', {
cwd: tmpDir, cwd: tmpDir,
stdio: ['ignore', 'ignore', 'ignore'], stdio: ['ignore', 'ignore', 'ignore'],
windowsHide: true, windowsHide: false,
}); });
} }
} }
@ -171,7 +171,7 @@ function nxCliPath() {
execSync(pmc.install, { execSync(pmc.install, {
cwd: tmpDir, cwd: tmpDir,
stdio: ['ignore', 'ignore', 'ignore'], stdio: ['ignore', 'ignore', 'ignore'],
windowsHide: true, windowsHide: false,
}); });
// Set NODE_PATH so that these modules can be used for module resolution // Set NODE_PATH so that these modules can be used for module resolution

View File

@ -1387,7 +1387,7 @@ function runInstall() {
output.log({ output.log({
title: `Running '${pmCommands.install}' to make sure necessary packages are installed`, title: `Running '${pmCommands.install}' to make sure necessary packages are installed`,
}); });
execSync(pmCommands.install, { stdio: [0, 1, 2], windowsHide: true }); execSync(pmCommands.install, { stdio: [0, 1, 2], windowsHide: false });
} }
export async function executeMigrations( export async function executeMigrations(

View File

@ -323,7 +323,7 @@ async function getCommitForVersionPlanFile(
exec( exec(
`git log --diff-filter=A --pretty=format:"%s|%h|%an|%ae|%b" -n 1 -- ${rawVersionPlan.absolutePath}`, `git log --diff-filter=A --pretty=format:"%s|%h|%an|%ae|%b" -n 1 -- ${rawVersionPlan.absolutePath}`,
{ {
windowsHide: true, windowsHide: false,
}, },
(error, stdout, stderr) => { (error, stdout, stderr) => {
if (error) { if (error) {

View File

@ -10,7 +10,7 @@ export async function execCommand(
...options, ...options,
stdio: ['pipe', 'pipe', 'pipe'], // stdin, stdout, stderr stdio: ['pipe', 'pipe', 'pipe'], // stdin, stdout, stderr
encoding: 'utf-8', encoding: 'utf-8',
windowsHide: true, windowsHide: false,
}); });
let stdout = ''; let stdout = '';

View File

@ -367,7 +367,7 @@ async function resolveGithubToken(hostname: string): Promise<string | null> {
return execSync(`gh auth token`, { return execSync(`gh auth token`, {
encoding: 'utf8', encoding: 'utf8',
stdio: 'pipe', stdio: 'pipe',
windowsHide: true, windowsHide: false,
}).trim(); }).trim();
} }
} }

View File

@ -14,7 +14,7 @@ export async function launchEditor(filePath: string) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const editorProcess = spawn(cmd, [...args, filePath], { const editorProcess = spawn(cmd, [...args, filePath], {
stdio: 'inherit', // This will ensure the editor uses the current terminal stdio: 'inherit', // This will ensure the editor uses the current terminal
windowsHide: true, windowsHide: false,
}); });
editorProcess.on('exit', (code) => { editorProcess.on('exit', (code) => {
@ -30,7 +30,7 @@ export async function launchEditor(filePath: string) {
function getGitConfig(key): string | null { function getGitConfig(key): string | null {
try { try {
return execSync(`git config --get ${key}`, { return execSync(`git config --get ${key}`, {
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim(); .trim();

View File

@ -762,7 +762,7 @@ function runPreVersionCommand(
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
stdio, stdio,
env, env,
windowsHide: true, windowsHide: false,
}); });
} catch (e) { } catch (e) {
const title = verbose const title = verbose

View File

@ -134,7 +134,7 @@ async function printTargetRunHelpInternal(
} else { } else {
const cp = exec(helpCommand, { const cp = exec(helpCommand, {
env, env,
windowsHide: true, windowsHide: false,
}); });
cp.on('exit', (code) => { cp.on('exit', (code) => {
process.exit(code); process.exit(code);

View File

@ -132,7 +132,7 @@ class BatchCommandRunner extends BatchFunctionRunner {
[this.projectNameEnv]: env[this.projectNameEnv], [this.projectNameEnv]: env[this.projectNameEnv],
[this.fileChangesEnv]: env[this.fileChangesEnv], [this.fileChangesEnv]: env[this.fileChangesEnv],
}, },
windowsHide: true, windowsHide: false,
}); });
commandExec.on('close', () => { commandExec.on('close', () => {
resolve(); resolve();

View File

@ -594,7 +594,7 @@ export class DaemonClient {
cwd: workspaceRoot, cwd: workspaceRoot,
stdio: ['ignore', this._out.fd, this._err.fd], stdio: ['ignore', this._out.fd, this._err.fd],
detached: true, detached: true,
windowsHide: true, windowsHide: false,
shell: false, shell: false,
env: { env: {
...process.env, ...process.env,

View File

@ -9,7 +9,7 @@ export function generateDaemonHelpOutput(): string {
*/ */
const res = spawnSync(process.execPath, ['./exec-is-server-available.js'], { const res = spawnSync(process.execPath, ['./exec-is-server-available.js'], {
cwd: __dirname, cwd: __dirname,
windowsHide: true, windowsHide: false,
}); });
const isServerAvailable = res?.stdout?.toString().trim().indexOf('true') > -1; const isServerAvailable = res?.stdout?.toString().trim().indexOf('true') > -1;

View File

@ -572,7 +572,7 @@ describe('Run Commands', () => {
...process.env, ...process.env,
...env(), ...env(),
}, },
windowsHide: true, windowsHide: false,
}); });
expect(exec).toHaveBeenNthCalledWith(2, `echo 'Hello Universe'`, { expect(exec).toHaveBeenNthCalledWith(2, `echo 'Hello Universe'`, {
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
@ -580,7 +580,7 @@ describe('Run Commands', () => {
...process.env, ...process.env,
...env(), ...env(),
}, },
windowsHide: true, windowsHide: false,
}); });
}); });
@ -603,7 +603,7 @@ describe('Run Commands', () => {
...process.env, ...process.env,
...env(), ...env(),
}, },
windowsHide: true, windowsHide: false,
}); });
expect(exec).toHaveBeenNthCalledWith(2, `echo 'Hello Universe'`, { expect(exec).toHaveBeenNthCalledWith(2, `echo 'Hello Universe'`, {
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
@ -611,7 +611,7 @@ describe('Run Commands', () => {
...process.env, ...process.env,
...env(), ...env(),
}, },
windowsHide: true, windowsHide: false,
}); });
}); });
@ -631,12 +631,12 @@ describe('Run Commands', () => {
expect(exec).toHaveBeenNthCalledWith(1, `echo 'Hello World'`, { expect(exec).toHaveBeenNthCalledWith(1, `echo 'Hello World'`, {
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
env: { ...process.env, FORCE_COLOR: `true`, ...env() }, env: { ...process.env, FORCE_COLOR: `true`, ...env() },
windowsHide: true, windowsHide: false,
}); });
expect(exec).toHaveBeenNthCalledWith(2, `echo 'Hello Universe'`, { expect(exec).toHaveBeenNthCalledWith(2, `echo 'Hello Universe'`, {
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
env: { ...process.env, FORCE_COLOR: `true`, ...env() }, env: { ...process.env, FORCE_COLOR: `true`, ...env() },
windowsHide: true, windowsHide: false,
}); });
}); });
}); });

View File

@ -392,7 +392,7 @@ function nodeProcess(
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
env, env,
cwd, cwd,
windowsHide: true, windowsHide: false,
}); });
childProcesses.add(childProcess); childProcesses.add(childProcess);

View File

@ -54,7 +54,7 @@ function nodeProcess(
stdio: ['inherit', 'inherit', 'inherit'], stdio: ['inherit', 'inherit', 'inherit'],
cwd, cwd,
env, env,
windowsHide: true, windowsHide: false,
}); });
} }

View File

@ -37,7 +37,7 @@ function getNxInitDate(): string | null {
try { try {
const nxInitIso = execSync( const nxInitIso = execSync(
'git log --diff-filter=A --follow --format=%aI -- nx.json | tail -1', 'git log --diff-filter=A --follow --format=%aI -- nx.json | tail -1',
{ stdio: 'pipe', windowsHide: true } { stdio: 'pipe', windowsHide: false }
) )
.toString() .toString()
.trim(); .trim();

View File

@ -56,7 +56,7 @@ export const createNodes: CreateNodes = [
? readFileSync(lockFilePath).toString() ? readFileSync(lockFilePath).toString()
: execSync(`bun ${lockFilePath}`, { : execSync(`bun ${lockFilePath}`, {
maxBuffer: 1024 * 1024 * 10, maxBuffer: 1024 * 1024 * 10,
windowsHide: true, windowsHide: false,
}).toString(); }).toString();
const lockFileHash = getLockFileHash(lockFileContents); const lockFileHash = getLockFileHash(lockFileContents);
@ -102,7 +102,7 @@ export const createDependencies: CreateDependencies = (
? readFileSync(lockFilePath).toString() ? readFileSync(lockFilePath).toString()
: execSync(`bun ${lockFilePath}`, { : execSync(`bun ${lockFilePath}`, {
maxBuffer: 1024 * 1024 * 10, maxBuffer: 1024 * 1024 * 10,
windowsHide: true, windowsHide: false,
}).toString(); }).toString();
const lockFileHash = getLockFileHash(lockFileContents); const lockFileHash = getLockFileHash(lockFileContents);

View File

@ -125,7 +125,7 @@ function defaultReadFileAtRevision(
: execSync(`git show ${revision}:${filePathInGitRepository}`, { : execSync(`git show ${revision}:${filePathInGitRepository}`, {
maxBuffer: TEN_MEGABYTES, maxBuffer: TEN_MEGABYTES,
stdio: ['pipe', 'pipe', 'ignore'], stdio: ['pipe', 'pipe', 'ignore'],
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim(); .trim();

View File

@ -234,7 +234,7 @@ export class Cache {
stdio: 'ignore', stdio: 'ignore',
detached: true, detached: true,
shell: false, shell: false,
windowsHide: true, windowsHide: false,
}); });
p.unref(); p.unref();
} catch (e) { } catch (e) {

View File

@ -110,7 +110,7 @@ function shouldRecordStats(): boolean {
try { try {
const stdout = execSync(pmc.getRegistryUrl, { const stdout = execSync(pmc.getRegistryUrl, {
encoding: 'utf-8', encoding: 'utf-8',
windowsHide: true, windowsHide: false,
}); });
const url = new URL(stdout.trim()); const url = new URL(stdout.trim());

View File

@ -299,7 +299,7 @@ function getMergeBase(base: string, head: string = 'HEAD') {
maxBuffer: TEN_MEGABYTES, maxBuffer: TEN_MEGABYTES,
cwd: workspaceRoot, cwd: workspaceRoot,
stdio: 'pipe', stdio: 'pipe',
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim(); .trim();
@ -309,7 +309,7 @@ function getMergeBase(base: string, head: string = 'HEAD') {
maxBuffer: TEN_MEGABYTES, maxBuffer: TEN_MEGABYTES,
cwd: workspaceRoot, cwd: workspaceRoot,
stdio: 'pipe', stdio: 'pipe',
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim(); .trim();
@ -329,7 +329,7 @@ function parseGitOutput(command: string): string[] {
return execSync(command, { return execSync(command, {
maxBuffer: TEN_MEGABYTES, maxBuffer: TEN_MEGABYTES,
cwd: workspaceRoot, cwd: workspaceRoot,
windowsHide: true, windowsHide: false,
}) })
.toString('utf-8') .toString('utf-8')
.split('\n') .split('\n')

View File

@ -5,7 +5,7 @@ export function deduceDefaultBase(): string {
try { try {
return ( return (
execSync('git config --get init.defaultBranch', { execSync('git config --get init.defaultBranch', {
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim() || nxDefaultBase .trim() || nxDefaultBase

View File

@ -9,10 +9,10 @@ try {
const { execSync } = require('child_process'); const { execSync } = require('child_process');
// NOTE: Using env vars because Windows PowerShell has its own handling of quotes (") messes up quotes in args, even if escaped. // NOTE: Using env vars because Windows PowerShell has its own handling of quotes (") messes up quotes in args, even if escaped.
const src = process.env.NX_IMPORT_SOURCE; const src = process.env.NX_IMPORT_SOURCE;
execSync('git read-tree --empty', { stdio: 'inherit', windowsHide: true }); execSync('git read-tree --empty', { stdio: 'inherit', windowsHide: false });
execSync(`git reset ${process.env.GIT_COMMIT} -- "${src}"`, { execSync(`git reset ${process.env.GIT_COMMIT} -- "${src}"`, {
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
}); });
} catch (error) { } catch (error) {
console.error(`Error executing Git commands: ${error}`); console.error(`Error executing Git commands: ${error}`);

View File

@ -23,7 +23,7 @@ describe('git utils tests', () => {
expect(result).toBe('origin-user/repo-name'); expect(result).toBe('origin-user/repo-name');
expect(execSync).toHaveBeenCalledWith('git remote -v', { expect(execSync).toHaveBeenCalledWith('git remote -v', {
stdio: 'pipe', stdio: 'pipe',
windowsHide: true, windowsHide: false,
}); });
}); });
@ -35,7 +35,7 @@ describe('git utils tests', () => {
expect(result).toBe('github'); expect(result).toBe('github');
expect(execSync).toHaveBeenCalledWith('git remote -v', { expect(execSync).toHaveBeenCalledWith('git remote -v', {
stdio: 'pipe', stdio: 'pipe',
windowsHide: true, windowsHide: false,
}); });
}); });
@ -49,7 +49,7 @@ describe('git utils tests', () => {
expect(result).toBe('github'); expect(result).toBe('github');
expect(execSync).toHaveBeenCalledWith('git remote -v', { expect(execSync).toHaveBeenCalledWith('git remote -v', {
stdio: 'pipe', stdio: 'pipe',
windowsHide: true, windowsHide: false,
}); });
}); });
@ -64,7 +64,7 @@ describe('git utils tests', () => {
expect(result).toBe('upstream-user/repo-name'); expect(result).toBe('upstream-user/repo-name');
expect(execSync).toHaveBeenCalledWith('git remote -v', { expect(execSync).toHaveBeenCalledWith('git remote -v', {
stdio: 'pipe', stdio: 'pipe',
windowsHide: true, windowsHide: false,
}); });
}); });
@ -79,7 +79,7 @@ describe('git utils tests', () => {
expect(result).toBeNull(); expect(result).toBeNull();
expect(execSync).toHaveBeenCalledWith('git remote -v', { expect(execSync).toHaveBeenCalledWith('git remote -v', {
stdio: 'pipe', stdio: 'pipe',
windowsHide: true, windowsHide: false,
}); });
}); });
@ -94,7 +94,7 @@ describe('git utils tests', () => {
expect(result).toBe('origin-user/repo-name'); expect(result).toBe('origin-user/repo-name');
expect(execSync).toHaveBeenCalledWith('git remote -v', { expect(execSync).toHaveBeenCalledWith('git remote -v', {
stdio: 'pipe', stdio: 'pipe',
windowsHide: true, windowsHide: false,
}); });
}); });
}); });

View File

@ -15,7 +15,7 @@ try {
const src = process.env.NX_IMPORT_SOURCE; const src = process.env.NX_IMPORT_SOURCE;
const dest = process.env.NX_IMPORT_DESTINATION; const dest = process.env.NX_IMPORT_DESTINATION;
const files = execSync(`git ls-files -z ${src}`, { const files = execSync(`git ls-files -z ${src}`, {
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim() .trim()

View File

@ -40,7 +40,7 @@ export class GitRepository {
getGitRootPath(cwd: string) { getGitRootPath(cwd: string) {
return execSync('git rev-parse --show-toplevel', { return execSync('git rev-parse --show-toplevel', {
cwd, cwd,
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim(); .trim();
@ -238,7 +238,7 @@ export function getGithubSlugOrNull(): string | null {
try { try {
const gitRemote = execSync('git remote -v', { const gitRemote = execSync('git remote -v', {
stdio: 'pipe', stdio: 'pipe',
windowsHide: true, windowsHide: false,
}).toString(); }).toString();
// If there are no remotes, we default to github // If there are no remotes, we default to github
if (!gitRemote || gitRemote.length === 0) { if (!gitRemote || gitRemote.length === 0) {
@ -304,7 +304,7 @@ export function commitChanges(
stdio: 'pipe', stdio: 'pipe',
input: commitMessage, input: commitMessage,
cwd: directory, cwd: directory,
windowsHide: true, windowsHide: false,
}); });
} catch (err) { } catch (err) {
if (directory) { if (directory) {
@ -326,7 +326,7 @@ export function getLatestCommitSha(): string | null {
return execSync('git rev-parse HEAD', { return execSync('git rev-parse HEAD', {
encoding: 'utf8', encoding: 'utf8',
stdio: 'pipe', stdio: 'pipe',
windowsHide: true, windowsHide: false,
}).trim(); }).trim();
} catch { } catch {
return null; return null;

View File

@ -81,7 +81,7 @@ export async function playwrightExecutor(
execSync(`${pmc.exec} playwright install`, { execSync(`${pmc.exec} playwright install`, {
cwd: workspaceRoot, cwd: workspaceRoot,
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
}); });
} }

View File

@ -166,7 +166,7 @@ function getBrowsersInstallTask() {
const pmc = getPackageManagerCommand(); const pmc = getPackageManagerCommand();
execSync(`${pmc.exec} playwright install`, { execSync(`${pmc.exec} playwright install`, {
cwd: workspaceRoot, cwd: workspaceRoot,
windowsHide: true, windowsHide: false,
}); });
}; };
} }

View File

@ -21,7 +21,7 @@ export function runCommandAsync(
{ {
cwd: opts.cwd ?? tmpProjPath(), cwd: opts.cwd ?? tmpProjPath(),
env: { ...process.env, ...opts.env }, env: { ...process.env, ...opts.env },
windowsHide: true, windowsHide: false,
}, },
(err, stdout, stderr) => { (err, stdout, stderr) => {
if (!opts.silenceError && err) { if (!opts.silenceError && err) {

View File

@ -21,7 +21,7 @@ export function runNxCommand(
const execSyncOptions: ExecOptions = { const execSyncOptions: ExecOptions = {
cwd, cwd,
env: { ...process.env, ...opts.env }, env: { ...process.env, ...opts.env },
windowsHide: true, windowsHide: false,
}; };
if (fileExists(tmpProjPath('package.json'))) { if (fileExists(tmpProjPath('package.json'))) {
const pmc = getPackageManagerCommand(detectPackageManager(cwd)); const pmc = getPackageManagerCommand(detectPackageManager(cwd));

View File

@ -21,7 +21,7 @@ function runNxNewCommand(args?: string, silent?: boolean) {
{ {
cwd: localTmpDir, cwd: localTmpDir,
...(silent && false ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}), ...(silent && false ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
windowsHide: true, windowsHide: false,
} }
); );
} }
@ -56,7 +56,7 @@ export function runPackageManagerInstall(silent: boolean = true) {
const install = execSync(pmc.install, { const install = execSync(pmc.install, {
cwd, cwd,
...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}), ...(silent ? { stdio: ['ignore', 'ignore', 'ignore'] } : {}),
windowsHide: true, windowsHide: false,
}); });
return install ? install.toString() : ''; return install ? install.toString() : '';
} }

View File

@ -72,7 +72,7 @@ export function podInstall(
execSync('touch .xcode.env', { execSync('touch .xcode.env', {
cwd: iosDirectory, cwd: iosDirectory,
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
}); });
} }
const podCommand = [ const podCommand = [
@ -83,7 +83,7 @@ export function podInstall(
execSync(podCommand, { execSync(podCommand, {
cwd: iosDirectory, cwd: iosDirectory,
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
}); });
} catch (e) { } catch (e) {
logger.error(podInstallErrorMessage); logger.error(podInstallErrorMessage);

View File

@ -20,7 +20,7 @@ export function callUpgrade(schema: Schema): 1 | Buffer {
}`, }`,
{ {
stdio: [0, 1, 2], stdio: [0, 1, 2],
windowsHide: true, windowsHide: false,
} }
); );
@ -86,7 +86,7 @@ export function callAutomigrate(
`${commandToRun} ${schema.autoAcceptAllPrompts ? '--yes' : ''}`, `${commandToRun} ${schema.autoAcceptAllPrompts ? '--yes' : ''}`,
{ {
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
} }
); );

View File

@ -20,7 +20,7 @@ export function callUpgrade(schema: Schema): 1 | Buffer {
}`, }`,
{ {
stdio: [0, 1, 2], stdio: [0, 1, 2],
windowsHide: true, windowsHide: false,
} }
); );
@ -84,7 +84,7 @@ export function callAutomigrate(
`${commandToRun} ${schema.autoAcceptAllPrompts ? '--yes' : ''}`, `${commandToRun} ${schema.autoAcceptAllPrompts ? '--yes' : ''}`,
{ {
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
} }
); );

View File

@ -19,7 +19,7 @@ export function nxViteBuildCoordinationPlugin(
async function buildChangedProjects() { async function buildChangedProjects() {
await new Promise<void>((res) => { await new Promise<void>((res) => {
activeBuildProcess = exec(options.buildCommand, { activeBuildProcess = exec(options.buildCommand, {
windowsHide: true, windowsHide: false,
}); });
activeBuildProcess.stdout.pipe(process.stdout); activeBuildProcess.stdout.pipe(process.stdout);
activeBuildProcess.stderr.pipe(process.stderr); activeBuildProcess.stderr.pipe(process.stderr);

View File

@ -36,7 +36,7 @@ export async function validateTypes(opts: {
{ {
cwd: opts.workspaceRoot, cwd: opts.workspaceRoot,
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
} }
); );
} }

View File

@ -172,7 +172,7 @@ export default async function* fileServerExecutor(
execFileSync(pmCmd, args, { execFileSync(pmCmd, args, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
shell: true, shell: true,
windowsHide: true, windowsHide: false,
}); });
} catch { } catch {
throw new Error( throw new Error(

View File

@ -53,7 +53,7 @@ export class WebpackNxBuildCoordinationPlugin {
try { try {
return await new Promise<void>((res) => { return await new Promise<void>((res) => {
this.buildCmdProcess = exec(this.buildCmd, { this.buildCmdProcess = exec(this.buildCmd, {
windowsHide: true, windowsHide: false,
}); });
this.buildCmdProcess.stdout.pipe(process.stdout); this.buildCmdProcess.stdout.pipe(process.stdout);

View File

@ -36,7 +36,7 @@ export function generatePreset(host: Tree, opts: NormalizedSchema) {
stdio: 'inherit', stdio: 'inherit',
shell: true, shell: true,
cwd: join(host.root, opts.directory), cwd: join(host.root, opts.directory),
windowsHide: true, windowsHide: false,
}; };
const pmc = getPackageManagerCommand(); const pmc = getPackageManagerCommand();
const executable = `${pmc.exec} nx`; const executable = `${pmc.exec} nx`;

View File

@ -64,7 +64,7 @@ export async function newGenerator(tree: Tree, opts: Schema) {
cwd: joinPathFragments(tree.root, options.directory), cwd: joinPathFragments(tree.root, options.directory),
stdio: stdio:
process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit', process.env.NX_GENERATE_QUIET === 'true' ? 'ignore' : 'inherit',
windowsHide: true, windowsHide: false,
}); });
} }
installPackagesTask( installPackagesTask(

View File

@ -10,7 +10,7 @@ export function getNpmPackageVersion(
{ {
stdio: ['pipe', 'pipe', 'ignore'], stdio: ['pipe', 'pipe', 'ignore'],
windowsHide: true, windowsHide: false,
} }
); );

View File

@ -5,7 +5,7 @@ export function deduceDefaultBase(): string {
try { try {
return ( return (
execSync('git config --get init.defaultBranch', { execSync('git config --get init.defaultBranch', {
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim() || nxDefaultBase .trim() || nxDefaultBase

View File

@ -46,7 +46,7 @@ async function run() {
stdio: 'inherit', stdio: 'inherit',
encoding: 'utf8', encoding: 'utf8',
windowsHide: true, windowsHide: false,
}); });
console.log('✅ - Finished installing packages!'); console.log('✅ - Finished installing packages!');
@ -54,7 +54,7 @@ async function run() {
execSync('pnpm nx format', { execSync('pnpm nx format', {
stdio: 'inherit', stdio: 'inherit',
encoding: 'utf8', encoding: 'utf8',
windowsHide: true, windowsHide: false,
}); });
console.log('✅ - Finished creating migrations!'); console.log('✅ - Finished creating migrations!');
} }

View File

@ -10,7 +10,7 @@ export async function generateDevkitDocumentation() {
const execSyncOptions: ExecSyncOptions = { const execSyncOptions: ExecSyncOptions = {
stdio: 'true' === 'true' ? 'inherit' : 'ignore', stdio: 'true' === 'true' ? 'inherit' : 'ignore',
// stdio: process.env.CI === 'true' ? 'inherit' : 'ignore', // stdio: process.env.CI === 'true' ? 'inherit' : 'ignore',
windowsHide: true, windowsHide: false,
}; };
execSync('nx run-many -t build -p devkit,typedoc-theme', execSyncOptions); execSync('nx run-many -t build -p devkit,typedoc-theme', execSyncOptions);

View File

@ -44,7 +44,7 @@ async function generate() {
function checkDocumentation() { function checkDocumentation() {
const output = execSync('git status --porcelain ./docs', { const output = execSync('git status --porcelain ./docs', {
windowsHide: true, windowsHide: false,
}).toString('utf-8'); }).toString('utf-8');
if (output) { if (output) {
@ -59,7 +59,7 @@ function checkDocumentation() {
console.log('\nChanged Docs:'); console.log('\nChanged Docs:');
execSync('git status --porcelain ./docs', { execSync('git status --porcelain ./docs', {
stdio: 'inherit', stdio: 'inherit',
windowsHide: true, windowsHide: false,
}); });
process.exit(1); process.exit(1);

View File

@ -63,7 +63,7 @@ function writeFile() {
// if no generated projects are found, generate one for nx and try this again // if no generated projects are found, generate one for nx and try this again
if (generatedGraphs.length === 0) { if (generatedGraphs.length === 0) {
execSync('nx run graph-client:generate-graph --directory ./ --name nx', { execSync('nx run graph-client:generate-graph --directory ./ --name nx', {
windowsHide: true, windowsHide: false,
}); });
writeFile(); writeFile();
return; return;

View File

@ -13,7 +13,7 @@ async function generateGraph(directory: string, name: string) {
try { try {
execSync( execSync(
'npx nx graph --file ./node_modules/.cache/nx-graph-gen/graph.html', 'npx nx graph --file ./node_modules/.cache/nx-graph-gen/graph.html',
{ cwd: directory, stdio: 'ignore', windowsHide: true } { cwd: directory, stdio: 'ignore', windowsHide: false }
); );
} catch { } catch {
console.error(`Could not run graph command in directory ${directory}`); console.error(`Could not run graph command in directory ${directory}`);

View File

@ -35,7 +35,7 @@ const VALID_AUTHORS_FOR_LATEST = [
execSync(`pnpm nx copy-native-package-directories nx`, { execSync(`pnpm nx copy-native-package-directories nx`, {
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
windowsHide: true, windowsHide: false,
}); });
// Expected to run as part of the Github `publish` workflow // Expected to run as part of the Github `publish` workflow
@ -45,13 +45,13 @@ const VALID_AUTHORS_FOR_LATEST = [
execSync('find ./build -name "*.node" -delete', { execSync('find ./build -name "*.node" -delete', {
stdio: [0, 1, 2], stdio: [0, 1, 2],
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
windowsHide: true, windowsHide: false,
}); });
execSync('pnpm nx run-many --target=artifacts', { execSync('pnpm nx run-many --target=artifacts', {
stdio: [0, 1, 2], stdio: [0, 1, 2],
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
windowsHide: true, windowsHide: false,
}); });
} }
@ -69,7 +69,7 @@ const VALID_AUTHORS_FOR_LATEST = [
execSync(versionCommand, { execSync(versionCommand, {
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
windowsHide: true, windowsHide: false,
}); });
}; };
@ -79,7 +79,7 @@ const VALID_AUTHORS_FOR_LATEST = [
isVerboseLogging = true; isVerboseLogging = true;
execSync('git status --ahead-behind', { execSync('git status --ahead-behind', {
windowsHide: true, windowsHide: false,
}); });
if (isRelativeVersionKeyword(options.version)) { if (isRelativeVersionKeyword(options.version)) {
@ -93,7 +93,7 @@ const VALID_AUTHORS_FOR_LATEST = [
execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, { execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, {
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
windowsHide: true, windowsHide: false,
}); });
let changelogCommand = `pnpm nx release changelog ${options.version} --interactive workspace`; let changelogCommand = `pnpm nx release changelog ${options.version} --interactive workspace`;
@ -113,7 +113,7 @@ const VALID_AUTHORS_FOR_LATEST = [
execSync(changelogCommand, { execSync(changelogCommand, {
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
windowsHide: true, windowsHide: false,
}); });
console.log( console.log(
@ -127,7 +127,7 @@ const VALID_AUTHORS_FOR_LATEST = [
execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, { execSync(`pnpm nx run-many -t add-extra-dependencies --parallel 8`, {
stdio: isVerboseLogging ? [0, 1, 2] : 'ignore', stdio: isVerboseLogging ? [0, 1, 2] : 'ignore',
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
windowsHide: true, windowsHide: false,
}); });
const distTag = determineDistTag(options.version); const distTag = determineDistTag(options.version);
@ -183,14 +183,14 @@ const VALID_AUTHORS_FOR_LATEST = [
execSync(publishCommand, { execSync(publishCommand, {
stdio: [0, 1, 2], stdio: [0, 1, 2],
maxBuffer: LARGE_BUFFER, maxBuffer: LARGE_BUFFER,
windowsHide: true, windowsHide: false,
}); });
if (!options.dryRun) { if (!options.dryRun) {
let version; let version;
if (['minor', 'major', 'patch'].includes(options.version)) { if (['minor', 'major', 'patch'].includes(options.version)) {
version = execSync(`npm view nx@${distTag} version`, { version = execSync(`npm view nx@${distTag} version`, {
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim(); .trim();
@ -271,12 +271,12 @@ function parseArgs() {
*/ */
const currentLatestVersion = execSync('npm view nx@latest version', { const currentLatestVersion = execSync('npm view nx@latest version', {
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim(); .trim();
const currentNextVersion = execSync('npm view nx@next version', { const currentNextVersion = execSync('npm view nx@next version', {
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim(); .trim();
@ -309,7 +309,7 @@ function parseArgs() {
// Get the current short git sha // Get the current short git sha
const gitSha = execSync('git rev-parse --short HEAD', { const gitSha = execSync('git rev-parse --short HEAD', {
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim(); .trim();
@ -382,7 +382,7 @@ function parseArgs() {
function getRegistry() { function getRegistry() {
return new URL( return new URL(
execSync('npm config get registry', { execSync('npm config get registry', {
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim() .trim()
@ -421,7 +421,7 @@ function determineDistTag(
} }
const currentLatestVersion = execSync('npm view nx version', { const currentLatestVersion = execSync('npm view nx version', {
windowsHide: true, windowsHide: false,
}) })
.toString() .toString()
.trim(); .trim();

View File

@ -9,7 +9,7 @@ console.log(`Comparing ${currentVersion} to npm versions`);
const majorVersion = major(currentVersion); const majorVersion = major(currentVersion);
const releasedVersions: string[] = JSON.parse( const releasedVersions: string[] = JSON.parse(
execSync(`npm show nx@^${majorVersion} version --json`, { execSync(`npm show nx@^${majorVersion} version --json`, {
windowsHide: true, windowsHide: false,
}).toString() }).toString()
); );
@ -26,10 +26,10 @@ if (currentVersion && latestVersion && gte(currentVersion, latestVersion)) {
); );
// We force recreate the branch in order to always be up to date and avoid merge conflicts within the automated workflow // We force recreate the branch in order to always be up to date and avoid merge conflicts within the automated workflow
execSync(`git branch -f ${branchName}`, { execSync(`git branch -f ${branchName}`, {
windowsHide: true, windowsHide: false,
}); });
execSync(`git push -f origin ${branchName}`, { execSync(`git push -f origin ${branchName}`, {
windowsHide: true, windowsHide: false,
}); });
} else { } else {
console.log(`Not publishing docs to ${branchName}`); console.log(`Not publishing docs to ${branchName}`);