fix(misc): avoid terminal popups when checking package manager version (#27329)
This commit is contained in:
parent
7e2266177d
commit
333ab7708f
@ -8,8 +8,9 @@ export function deduceDefaultBase(): string {
|
||||
const nxDefaultBase = 'main';
|
||||
try {
|
||||
return (
|
||||
execSync('git config --get init.defaultBranch').toString().trim() ||
|
||||
nxDefaultBase
|
||||
execSync('git config --get init.defaultBranch', { windowsHide: true })
|
||||
.toString()
|
||||
.trim() || nxDefaultBase
|
||||
);
|
||||
} catch {
|
||||
return nxDefaultBase;
|
||||
|
||||
@ -4,7 +4,9 @@ import { output } from '../output';
|
||||
|
||||
export function checkGitVersion(): string | null | undefined {
|
||||
try {
|
||||
let gitVersionOutput = execSync('git --version').toString().trim();
|
||||
let gitVersionOutput = execSync('git --version', { windowsHide: true })
|
||||
.toString()
|
||||
.trim();
|
||||
return gitVersionOutput.match(/[0-9]+\.[0-9]+\.+[0-9]+/)?.[0];
|
||||
} catch {
|
||||
return null;
|
||||
|
||||
@ -137,7 +137,10 @@ function shouldRecordStats(): boolean {
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const stdout = execSync(pmc.getRegistryUrl, { encoding: 'utf-8' });
|
||||
const stdout = execSync(pmc.getRegistryUrl, {
|
||||
encoding: 'utf-8',
|
||||
windowsHide: true,
|
||||
});
|
||||
const url = new URL(stdout.trim());
|
||||
|
||||
// don't record stats when testing locally
|
||||
|
||||
@ -9,6 +9,7 @@ export function showNxWarning(workspaceName: string) {
|
||||
execSync('nx --version', {
|
||||
cwd: pathToRunNxCommand,
|
||||
stdio: ['ignore', 'ignore', 'ignore'],
|
||||
windowsHide: true,
|
||||
});
|
||||
} catch (e) {
|
||||
// no nx found
|
||||
|
||||
@ -123,6 +123,7 @@ export function getPackageManagerVersion(
|
||||
const version = execSync(`${packageManager} --version`, {
|
||||
cwd,
|
||||
encoding: 'utf-8',
|
||||
windowsHide: true,
|
||||
}).trim();
|
||||
pmVersionCache.set(packageManager, version);
|
||||
return version;
|
||||
|
||||
@ -203,6 +203,7 @@ export function getPackageManagerVersion(
|
||||
version = execSync(`${packageManager} --version`, {
|
||||
cwd,
|
||||
encoding: 'utf-8',
|
||||
windowsHide: true,
|
||||
}).trim();
|
||||
} catch {
|
||||
if (existsSync(join(cwd, 'package.json'))) {
|
||||
@ -411,7 +412,10 @@ export async function resolvePackageVersionUsingInstallation(
|
||||
|
||||
try {
|
||||
const pmc = getPackageManagerCommand();
|
||||
await execAsync(`${pmc.add} ${packageName}@${version}`, { cwd: dir });
|
||||
await execAsync(`${pmc.add} ${packageName}@${version}`, {
|
||||
cwd: dir,
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
const { packageJson } = readModulePackageJson(packageName, [dir]);
|
||||
|
||||
@ -441,7 +445,9 @@ export async function packageRegistryView(
|
||||
pm = 'npm';
|
||||
}
|
||||
|
||||
const { stdout } = await execAsync(`${pm} view ${pkg}@${version} ${args}`);
|
||||
const { stdout } = await execAsync(`${pm} view ${pkg}@${version} ${args}`, {
|
||||
windowsHide: true,
|
||||
});
|
||||
return stdout.toString().trim();
|
||||
}
|
||||
|
||||
@ -464,7 +470,10 @@ export async function packageRegistryPack(
|
||||
pm = 'npm';
|
||||
}
|
||||
|
||||
const { stdout } = await execAsync(`${pm} pack ${pkg}@${version}`, { cwd });
|
||||
const { stdout } = await execAsync(`${pm} pack ${pkg}@${version}`, {
|
||||
cwd,
|
||||
windowsHide: true,
|
||||
});
|
||||
|
||||
const tarballPath = stdout.trim();
|
||||
return { tarballPath };
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user