diff --git a/__tests__/cli.spec.ts b/__tests__/cli.spec.ts index fee6859..f8bbf4a 100644 --- a/__tests__/cli.spec.ts +++ b/__tests__/cli.spec.ts @@ -33,8 +33,25 @@ test('prompts for the project name if none supplied', () => { expect(stdout).toContain('Project name:') }) -test('prompts for project template if none supplied when target dir is current directory', () => { +test('prompts for the framework if none supplied when target dir is current directory', () => { fs.mkdirSync(generatePath, { recursive: true }) const { stdout } = run(['.'], { cwd: generatePath }) expect(stdout).toContain('Project template:') }) + +test('prompts for the framework if none supplied', () => { + const { stdout } = run([projectName]) + expect(stdout).toContain('Project template:') +}) + +test('asks to overwrite non-empty target directory', () => { + createNonEmptyDir() + const { stdout } = run([projectName], { cwd: __dirname }) + expect(stdout).toContain(`Target directory "${projectName}" is not empty.`) +}) + +test('asks to overwrite non-empty current directory', () => { + createNonEmptyDir() + const { stdout } = run(['.'], { cwd: generatePath }) + expect(stdout).toContain(`Current directory is not empty.`) +}) \ No newline at end of file diff --git a/package.json b/package.json index 9b42e94..5bd5cb5 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "starter" ], "scripts": { + "preinstall": "npx only-allow pnpm", "watch": "vite build --watch", "build": "vite build", "prepublishOnly": "npm run build && npm run test", @@ -50,5 +51,6 @@ }, "engines": { "node": "^14.18.0 || >=16.0.0" - } + }, + "packageManager": "pnpm@8.0.0" }