Skip to content

Commit

Permalink
fix: remove yarn.lock if yarn wasnt selected (#1365)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Apr 9, 2024
1 parent 9319f53 commit a8d3bfa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/commands/generate.ts
Expand Up @@ -255,6 +255,10 @@ export default class Generate extends GeneratorCommand<typeof Generate> {

await writeFile(join(location, '.gitignore'), updated)

if (packageManager !== 'yarn') {
await rm(join(location, 'yarn.lock'))
}

await exec(`${packageManager} install`, {cwd: location, silent: false})
await exec(`${join(location, 'node_modules', '.bin', 'oclif')} readme`, {
cwd: location,
Expand Down
14 changes: 14 additions & 0 deletions test/integration/cli.test.ts
Expand Up @@ -55,6 +55,20 @@ describe(`Generated CLI Integration Tests ${MODULE_TYPE} + ${PACKAGE_MANAGER} +
const result = await exec(`${cliBinRun} hello world`, {cwd: cliDir})
expect(result.code).to.equal(0)
expect(result.stdout).to.equal('hello world! (./src/commands/hello/world.ts)\n')

if (PACKAGE_MANAGER === 'yarn') {
expect(existsSync(join(cliDir, 'yarn.lock'))).to.be.true
}

if (PACKAGE_MANAGER === 'npm') {
expect(existsSync(join(cliDir, 'package-lock.json'))).to.be.true
expect(existsSync(join(cliDir, 'yarn.lock'))).to.be.false
}

if (PACKAGE_MANAGER === 'pnpm') {
expect(existsSync(join(cliDir, 'pnpm-lock.yaml'))).to.be.true
expect(existsSync(join(cliDir, 'yarn.lock'))).to.be.false
}
})

it('should generate a new command', async () => {
Expand Down

0 comments on commit a8d3bfa

Please sign in to comment.