Skip to content

Commit f69cd4c

Browse files
committed
feat: replace child_process exec with execa
Signed-off-by: Sebastian Beltran <[email protected]>
1 parent 053cf42 commit f69cd4c

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

lib/test.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const context = require('./context')
44
const github = require('./github')
55
const gitURLParse = require('git-url-parse')
6-
const { exec } = require('child_process')
6+
const exec = require('execa').execa
77
const logger = require('./logger')
88
const tmp = require('tmp')
99
const { cp } = require('fs/promises')
@@ -25,20 +25,30 @@ module.exports = async function ({ dependents }) {
2525
const parentDependencyLink = await context.getDependencyLink(parentRepositoryInfo.owner, parentRepositoryInfo.name, parentBranchName)
2626
debug('Commit URL to test:', parentDependencyLink)
2727

28-
for (const { repository: url, pullRequest, sha, mode } of dependents) {
28+
for (let { repository: url, pullRequest, sha, mode } of dependents) {
2929
const dependentRepositoryInfo = gitURLParse(url)
3030

3131
if (mode === 'download') {
3232
debug('Generating tarball')
33-
exec('npm pack')
33+
34+
await exec('npm', ['pack'])
35+
3436
const { name: tmpDir } = tmp.dirSync()
3537

3638
debug(`Temporary directory: ${tmpDir}`)
39+
3740
debug(`Copying package to ${tmpDir}`)
41+
3842
cp(`${parentPkgJSON.name}-${parentPkgJSON.version}.tgz`, path.join(tmpDir, `${parentPkgJSON.name}-${parentPkgJSON.version}.tgz`))
3943

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+
4050
debug(`Cloning dependent repository ${url} into ${tmpDir}`)
41-
exec(`git clone ${url} ${tmpDir}`, { cwd: tmpDir })
51+
await exec('git', ['clone', '--depth=1', url, tmpDir])
4252
} else {
4353
const dependentPkgJson = await github.getPackageJson(dependentRepositoryInfo.owner, dependentRepositoryInfo.name, sha)
4454
debug(`Dependent module: ${dependentRepositoryInfo.owner}/${dependentRepositoryInfo.name}, sha ${sha}`)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"colors": "1.4.0",
3535
"debug": "^4.3.1",
3636
"dotenv": "^16.0.0",
37+
"execa": "^9.6.0",
3738
"git-url-parse": "^11.1.2",
3839
"joi": "^17.2.1",
3940
"simple-git": "~3.15.0",

0 commit comments

Comments
 (0)