diff --git a/index.ts b/index.ts index 772c7ec..467f735 100644 --- a/index.ts +++ b/index.ts @@ -29,7 +29,6 @@ async function configureProject() { } for (const workspace of await getWorkspaces()) { - const packageJson = await Bun.file(root('./package.json')).json() - reset(workspace, packageJson) + await reset(workspace) await configureProject() } diff --git a/state.ts b/state.ts index 60151dd..995282e 100644 --- a/state.ts +++ b/state.ts @@ -1,5 +1,6 @@ import { join } from 'node:path' -import type { PackageJson, State } from './types' +import Bun from 'bun' +import type { State } from './types' export const state: State = { options: {}, @@ -14,10 +15,13 @@ export const fileExtension = () => (state.language === 'javascript' ? 'js' : 'ts export const root = (file: string) => process.cwd().includes('node_modules') ? join(process.cwd(), '../..', state.directory, file) : join(process.cwd(), state.directory, file) -export const reset = ({ path, root }: { path: string; root: boolean }, packageJson: PackageJson) => { +export async function reset({ path, root: isRoot }: { path: string; root: boolean }) { state.options = {} state.language = 'json' - state.packageJson = packageJson state.directory = path - state.root = root + state.root = isRoot + + const packageJson = await Bun.file(root('./package.json')).json() + + state.packageJson = packageJson }