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';
|
const nxDefaultBase = 'main';
|
||||||
try {
|
try {
|
||||||
return (
|
return (
|
||||||
execSync('git config --get init.defaultBranch').toString().trim() ||
|
execSync('git config --get init.defaultBranch', { windowsHide: true })
|
||||||
nxDefaultBase
|
.toString()
|
||||||
|
.trim() || nxDefaultBase
|
||||||
);
|
);
|
||||||
} catch {
|
} catch {
|
||||||
return nxDefaultBase;
|
return nxDefaultBase;
|
||||||
|
|||||||
@ -4,7 +4,9 @@ import { output } from '../output';
|
|||||||
|
|
||||||
export function checkGitVersion(): string | null | undefined {
|
export function checkGitVersion(): string | null | undefined {
|
||||||
try {
|
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];
|
return gitVersionOutput.match(/[0-9]+\.[0-9]+\.+[0-9]+/)?.[0];
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@ -137,7 +137,10 @@ function shouldRecordStats(): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
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());
|
const url = new URL(stdout.trim());
|
||||||
|
|
||||||
// don't record stats when testing locally
|
// don't record stats when testing locally
|
||||||
|
|||||||
@ -9,6 +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,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// no nx found
|
// no nx found
|
||||||
|
|||||||
@ -123,6 +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,
|
||||||
}).trim();
|
}).trim();
|
||||||
pmVersionCache.set(packageManager, version);
|
pmVersionCache.set(packageManager, version);
|
||||||
return version;
|
return version;
|
||||||
|
|||||||
@ -203,6 +203,7 @@ export function getPackageManagerVersion(
|
|||||||
version = execSync(`${packageManager} --version`, {
|
version = execSync(`${packageManager} --version`, {
|
||||||
cwd,
|
cwd,
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
|
windowsHide: true,
|
||||||
}).trim();
|
}).trim();
|
||||||
} catch {
|
} catch {
|
||||||
if (existsSync(join(cwd, 'package.json'))) {
|
if (existsSync(join(cwd, 'package.json'))) {
|
||||||
@ -411,7 +412,10 @@ export async function resolvePackageVersionUsingInstallation(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const pmc = getPackageManagerCommand();
|
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]);
|
const { packageJson } = readModulePackageJson(packageName, [dir]);
|
||||||
|
|
||||||
@ -441,7 +445,9 @@ export async function packageRegistryView(
|
|||||||
pm = 'npm';
|
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();
|
return stdout.toString().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,7 +470,10 @@ export async function packageRegistryPack(
|
|||||||
pm = 'npm';
|
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();
|
const tarballPath = stdout.trim();
|
||||||
return { tarballPath };
|
return { tarballPath };
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user