2017-12-07 10 views
0

nodegit을 사용하여 저장소를 복제하고 getHeadCommit()을 호출하면 노드 프로세스가 디렉토리를 보유하므로 코드 (fs-extra remove) 또는 OS에 의해 제거되지 않습니다 .nodegit : getHeadCommit()은 디렉토리 (libgit2)를 보유합니다.

console.log((async(): Promise<void> => { 
    const tempDirectory: string = path.join(process.cwd(), '.tmp'); 

    console.log('clone'); 
    const repository: nodegit.Repository = await nodegit.Clone.clone(
     'ssh://[email protected]***.git', 
     tempDirectory, 
     { 
      checkoutBranch: 'master', 
      fetchOpts: { 
       callbacks: { 
        certificateCheck:(): number => 1, 
        credentials: (url: string, userName: string): nodegit.Cred => 
         nodegit.Cred.sshKeyNew(
          userName, 
          path.join(os.homedir(), '.ssh', 'id_rsa.pub'), 
          path.join(os.homedir(), '.ssh', 'id_rsa'), 
          '' 
         ) 
       } 
      } 
     } 
    ); 

    console.log('get head commit'); 
    const commit: nodegit.Commit = await repository.getHeadCommit(); 

    console.log('remove'); 
    await fse.remove(tempDirectory); // Here Node hangs 

    console.log('end'); 
})()); 

오류 메시지 :

Error: EBUSY: resource busy or locked, unlink '***\.tmp\.git\objects\pack\pack-27924883cff8a0039ced57d07bad35459885ff9d.pack' 

내 코드에서 오류가 있습니까? 또는 repository.getHeadCommit()을 사용한 후 저장소 디렉토리를 해제하는 방법이 nodegit에 있습니까?

답변

0

죄송합니다. free 메소드가 누락되었습니다. 문제가 해결되었습니다.