···11+---
22+"@bomb.sh/tools": patch
33+---
44+55+Fixes the `bsh init` command—it now points at the directory the template was actually cloned into.
66+77+`init` / `init .` now scaffolds into the current directory in-place and uses the current directory's basename as the project name.
+10-4
src/commands/init.ts
···11import { readFile, writeFile } from 'node:fs/promises';
22+import { basename } from 'node:path';
23import { cwd } from 'node:process';
34import { pathToFileURL } from 'node:url';
45import { x } from 'tinyexec';
···78export async function init(ctx: CommandContext) {
89 const [_name = '.'] = ctx.args;
910 const cwdUrl = pathToFileURL(`${cwd()}/`);
1010- const name =
1111- _name === '.' ? new URL('../', cwdUrl).pathname.split('/').filter(Boolean).pop()! : _name;
1212- const dest = new URL('./.temp/', cwdUrl);
1313- for await (const line of x('pnpx', ['giget@latest', 'gh:bombshell-dev/template', name])) {
1111+ // `.` scaffolds into the current directory; otherwise clone into a new `./<name>/`.
1212+ const inPlace = _name === '.';
1313+ const name = inPlace ? basename(cwd()) : _name;
1414+ const target = inPlace ? '.' : name;
1515+ const dest = inPlace ? cwdUrl : new URL(`./${name}/`, cwdUrl);
1616+ const gigetArgs = ['giget@latest', 'gh:bombshell-dev/template', target];
1717+ // `--force` lets the template extract into an existing (non-empty) directory.
1818+ if (inPlace) gigetArgs.push('--force');
1919+ for await (const line of x('pnpx', gigetArgs)) {
1420 console.log(line);
1521 }
1622