Skip to content
Open
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
6 changes: 2 additions & 4 deletions packages/create/src/add-to-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,9 @@ export async function addToApp(
}

if (!options?.forced && (await hasPendingGitChanges(environment, cwd))) {
environment.error(
'You have pending git changes.',
'Please commit or stash them before adding add-ons.',
throw new Error(
'You have pending git changes. Please commit or stash them before adding add-ons.',
)
return
}

environment.intro(`Adding ${addOns.join(', ')} to the project...`)
Expand Down
11 changes: 11 additions & 0 deletions packages/create/tests/add-to-app.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,17 @@ describe('runNewCommands', () => {
})

describe('addToApp', () => {
it('rejects pending Git changes before adding an add-on', async () => {
const { environment } = createMemoryEnvironment('/foo')
environment.startRun()
await environment.writeFile('/foo/.cta.json', JSON.stringify(fakeCTAJSON))
environment.execute = () => Promise.resolve({ stdout: '?? pending.txt' })

await expect(addToApp(environment, ['test'], '/foo')).rejects.toThrow(
'You have pending git changes. Please commit or stash them before adding add-ons.',
)
})

it('should add an add-on', async () => {
const { environment, output } = createMemoryEnvironment('/foo')
environment.startRun()
Expand Down