-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathclone.js
39 lines (36 loc) · 846 Bytes
/
clone.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
'use strict';
const Git = require("nodegit");
const pkg = require('./package');
const cnst = require('./constant');
const Clone = Git.Clone.clone;
/*
if you use not NFS filesystem, error would comes to you!
-----------------------
Failed to mmap. Could not write data: Invalid argument
Error: Failed to mmap. Could not write data: Invalid argument
at Error (native)
-----------------------
help from GitHub: https://github.com/nodegit/nodegit/issues/1115
it's the filesystem cause it
*/
let cloneOptions = {};
cloneOptions.fetchOpts = {
callbacks: {
certificateCheck: () => {
return 1;
}
}
};
// 复制当前repo仓库
Clone(
pkg.repository.url,
`${cnst.tmp_dir}/${pkg.name}`,
cloneOptions
)
.then((repo) => {
console.log('repo done!');
})
.catch((e) => {
console.log(e.message);
console.log(e.stack);
});