Skip to content

Commit 7ee3d14

Browse files
lidelhugomrdias
authored andcommitted
feat: support lockfiles during text-external (#450)
* feat: support lockfiles during text-external This change detects presence of yarn.lock or package-lock.json and executes dependency install using optimized command, speeding up the build. License: MIT Signed-off-by: Marcin Rataj <[email protected]> * feat: support npm-shrinkwrap.json during test-external License: MIT Signed-off-by: Marcin Rataj <[email protected]>
1 parent 5ddc875 commit 7ee3d14

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

src/test-external/index.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,30 @@ const isMonoRepo = (targetDir) => {
3838
return fs.existsSync(path.join(targetDir, 'lerna.json'))
3939
}
4040

41+
const hasNpmLock = (targetDir) => {
42+
return fs.existsSync(path.join(targetDir, 'package-lock.json')) ||
43+
fs.existsSync(path.join(targetDir, 'npm-shrinkwrap.json'))
44+
}
45+
46+
const hasYarnLock = (targetDir) => {
47+
return fs.existsSync(path.join(targetDir, 'yarn.lock'))
48+
}
49+
4150
const installDependencies = async (targetDir) => {
4251
console.info('Installing dependencies') // eslint-disable-line no-console
43-
await exec('npm', ['install'], {
44-
cwd: targetDir
45-
})
52+
if (hasYarnLock(targetDir)) {
53+
await exec('yarn', ['install'], {
54+
cwd: targetDir
55+
})
56+
} else if (hasNpmLock(targetDir)) {
57+
await exec('npm', ['ci'], {
58+
cwd: targetDir
59+
})
60+
} else {
61+
await exec('npm', ['install'], {
62+
cwd: targetDir
63+
})
64+
}
4665
}
4766

4867
const linkIPFSInDir = async (targetDir, ipfsDir, ipfsPkg, httpClientPkg) => {

0 commit comments

Comments
 (0)