diff --git a/packages/cli/src/generators/app.ts b/packages/cli/src/generators/app.ts index 20ceada5d5..ba6922dd1c 100644 --- a/packages/cli/src/generators/app.ts +++ b/packages/cli/src/generators/app.ts @@ -159,7 +159,8 @@ class AppGenerator extends Generator { if (gitInitResult.status === 0) { this.commitChanges() } else { - log.error('Failed to run git init.') + log.warning('Failed to run git init.') + log.warning('Find out more about how to install git here: https://git-scm.com/downloads.') } } diff --git a/packages/cli/test/generators/app.test.ts b/packages/cli/test/generators/app.test.ts index 081effd5af..28d36e29b3 100644 --- a/packages/cli/test/generators/app.test.ts +++ b/packages/cli/test/generators/app.test.ts @@ -1,5 +1,6 @@ import * as fs from 'fs-extra' import spawn from 'cross-spawn' +import {log} from '@blitzjs/server' import AppGenerator from '../../src/generators/app' @@ -20,6 +21,7 @@ jest.mock( start: jest.fn().mockImplementation(() => ({succeed: jest.fn()})), } }), + warning: jest.fn(), }, } }), @@ -128,4 +130,22 @@ describe('AppGenerator', () => { stdio: 'ignore', }) }) + + describe('when git init fails', () => { + it('logs warn with instructions', async () => { + // @ts-ignore (TS complains about reassign) + spawn.sync = jest.fn().mockImplementation((command, options) => { + if (command === 'git' && options[0] === 'init') { + return {status: 1} + } + return {status: 0} + }) + await generator.run() + + expect(log.warning).toHaveBeenCalledWith('Failed to run git init.') + expect(log.warning).toHaveBeenCalledWith( + 'Find out more about how to install git here: https://git-scm.com/downloads.', + ) + }) + }) })