11import { execSync , spawn } from 'child_process'
2- import path from 'path'
3- import { rootPath } from './shared'
2+ import { resolveConfig } from './config'
43import { exists , makeDir } from './fs'
4+ import { join } from './path'
55import { analyzeUrl , composeUrl } from './shared/url'
66import { Repo } from './types'
77
8- export function repoDest ( repo : Repo ) {
9- return path . join ( rootPath , repo . host , repo . user , repo . name )
8+ export async function repoDest ( repo : Repo ) {
9+ const { root } = await resolveConfig ( )
10+ return join ( root , repo . host , repo . user , repo . name )
1011}
1112
1213function git ( cmd : string , dest : string , ...args : string [ ] ) {
@@ -19,7 +20,7 @@ export const username = getUsername()
1920
2021export async function clone ( repoUrl : string , ...args : string [ ] ) {
2122 const repo = analyzeUrl ( repoUrl )
22- const dest = repoDest ( repo )
23+ const dest = await repoDest ( repo )
2324
2425 if ( ! ( await exists ( dest ) ) ) {
2526 await makeDir ( dest )
@@ -30,7 +31,7 @@ export async function clone(repoUrl: string, ...args: string[]) {
3031
3132export async function init ( repoUrl : string , ...args : string [ ] ) {
3233 const repo = analyzeUrl ( repoUrl )
33- const dest = repoDest ( repo )
34+ const dest = await repoDest ( repo )
3435
3536 if ( ! ( await exists ( dest ) ) ) {
3637 await makeDir ( dest )
0 commit comments