3
3
const context = require ( './context' )
4
4
const github = require ( './github' )
5
5
const gitURLParse = require ( 'git-url-parse' )
6
- const { exec } = require ( 'child_process' )
6
+ const exec = require ( 'execa' ) . execa
7
7
const logger = require ( './logger' )
8
8
const tmp = require ( 'tmp' )
9
9
const { cp } = require ( 'fs/promises' )
@@ -25,20 +25,30 @@ module.exports = async function ({ dependents }) {
25
25
const parentDependencyLink = await context . getDependencyLink ( parentRepositoryInfo . owner , parentRepositoryInfo . name , parentBranchName )
26
26
debug ( 'Commit URL to test:' , parentDependencyLink )
27
27
28
- for ( const { repository : url , pullRequest, sha, mode } of dependents ) {
28
+ for ( let { repository : url , pullRequest, sha, mode } of dependents ) {
29
29
const dependentRepositoryInfo = gitURLParse ( url )
30
30
31
31
if ( mode === 'download' ) {
32
32
debug ( 'Generating tarball' )
33
- exec ( 'npm pack' )
33
+
34
+ await exec ( 'npm' , [ 'pack' ] )
35
+
34
36
const { name : tmpDir } = tmp . dirSync ( )
35
37
36
38
debug ( `Temporary directory: ${ tmpDir } ` )
39
+
37
40
debug ( `Copying package to ${ tmpDir } ` )
41
+
38
42
cp ( `${ parentPkgJSON . name } -${ parentPkgJSON . version } .tgz` , path . join ( tmpDir , `${ parentPkgJSON . name } -${ parentPkgJSON . version } .tgz` ) )
39
43
44
+ if ( url . startsWith ( 'git+http' ) ) {
45
+ url = url . replace ( 'git+http' , 'http' )
46
+ } else if ( url . startsWith ( 'git://' ) ) {
47
+ url = url . replace ( 'git://' , 'http://' )
48
+ }
49
+
40
50
debug ( `Cloning dependent repository ${ url } into ${ tmpDir } ` )
41
- exec ( ` git clone ${ url } ${ tmpDir } ` , { cwd : tmpDir } )
51
+ await exec ( ' git' , [ ' clone' , '--depth=1' , url , tmpDir ] )
42
52
} else {
43
53
const dependentPkgJson = await github . getPackageJson ( dependentRepositoryInfo . owner , dependentRepositoryInfo . name , sha )
44
54
debug ( `Dependent module: ${ dependentRepositoryInfo . owner } /${ dependentRepositoryInfo . name } , sha ${ sha } ` )
0 commit comments