diff --git a/fontes/interface-linha-comando/novo/index.ts b/fontes/interface-linha-comando/novo/index.ts index 999f38f..2c31801 100644 --- a/fontes/interface-linha-comando/novo/index.ts +++ b/fontes/interface-linha-comando/novo/index.ts @@ -108,7 +108,7 @@ export async function detectarGerenciadorDePacotes( break; } case 'yarn': { - execSync('yarn init', { cwd: diretorioProjeto }); + execSync('yarn init -y', { cwd: diretorioProjeto }); execSync('yarn add liquido@latest', { cwd: diretorioProjeto }); break; } diff --git a/testes/liquido.test.ts b/testes/liquido.test.ts index 8de951b..4ff5088 100644 --- a/testes/liquido.test.ts +++ b/testes/liquido.test.ts @@ -337,6 +337,31 @@ describe('Liquido', () => { ); }); + + it('Deve executar os comandos do yarn para inicializar o projeto', async () => { + jest.clearAllMocks(); + + (ChildProcess.execSync as jest.Mock).mockImplementation( + () => Buffer.from('') + ); + + await detectarGerenciadorDePacotes( + 'yarn', + caminhoDiretorioProjeto + ); + + expect(ChildProcess.execSync).toHaveBeenCalledWith( + 'yarn init -y', + { cwd: caminhoDiretorioProjeto } + ); + expect(ChildProcess.execSync).toHaveBeenCalledWith( + 'yarn add liquido@latest', + { cwd: caminhoDiretorioProjeto } + ); + + }); + + it('Deve usar o nome da pasta quando o nome do projeto é criado com "." ou "./"', async () => { const spyCwd = jest