Skip to content

Commit a0624ef

Browse files
committed
Check for yarn.lock while isntalling
1 parent 8676035 commit a0624ef

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/lib/setup.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import path from 'path';
2+
import fs from 'fs.promised';
13
import spawn from 'cross-spawn-promise';
24
import { commandExists } from './shell';
35

@@ -16,6 +18,12 @@ const install = async (yarn, cwd, packages, env) => {
1618
let isYarnAvailable = await commandExists('yarn');
1719
let toInstall = packages.filter(Boolean);
1820

21+
// pass null to use yarn only if yarn.lock is present
22+
if (!yarn) {
23+
try { yarn = await fs.stat(path.resolve(cwd, 'yarn.lock')).isFile(); }
24+
catch (e) { yarn = false; }
25+
}
26+
1927
if (isYarnAvailable && yarn) {
2028
let args = ['add'];
2129
if (isDev) {

0 commit comments

Comments
 (0)