Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(cli): only check for git on init #3846

Merged
merged 4 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/api/cli/src/electron-forge.ts

This comment was marked as spam.

Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,24 @@ program
.command('package', 'Package the current Electron application')
.command('make', 'Generate distributables for the current Electron application')
.command('publish', 'Publish the current Electron application')
.hook('preSubcommand', async () => {
.hook('preSubcommand', async (_command, subcommand) => {
if (!process.argv.includes('--help') && !process.argv.includes('-h')) {
const runner = new Listr<never>(
const runner = new Listr<{
command: string;
}>(
[
{
title: 'Checking your system',
task: async (_, task) => {
task: async (ctx, task) => {
ctx.command = subcommand.name();
return await checkSystem(task);
},
},
],
{
concurrent: false,
exitOnError: false,
fallbackRendererCondition: Boolean(process.env.DEBUG) || Boolean(process.env.CI),
}
);

Expand Down
7 changes: 5 additions & 2 deletions packages/api/cli/src/util/check-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,16 @@ type SystemCheckContext = {
node: boolean;
packageManager: boolean;
};
export async function checkSystem(task: ForgeListrTask<never>) {

export async function checkSystem(callerTask: ForgeListrTask<{ command: string }>) {
if (!(await fs.pathExists(SKIP_SYSTEM_CHECK))) {
d('checking system, create ~/.skip-forge-system-check to stop doing this');
return task.newListr<SystemCheckContext>(
return callerTask.newListr<{ command: string } & SystemCheckContext>(
[
{
title: 'Checking git exists',
// We only call the `initGit` helper in the `init` and `import` commands
enabled: (ctx): boolean => ctx.command === 'init' || ctx.command === 'import',
task: async (_, task) => {
const gitVersion = await getGitVersion();
if (gitVersion) {
Expand Down