Skip to content

Commit fe9ce73

Browse files
committed
fix: add pnpm detection support
1 parent eeaf128 commit fe9ce73

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/command/install/index.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
const hasYarn = require('has-yarn');
22
const Listr = require('listr');
33
const { catchError, throwError } = require('rxjs/operators');
4+
const { existsSync } = require('fs');
5+
const { join } = require('path');
46
const exec = require('../../exec');
57

8+
function hasPnpm() {
9+
try {
10+
return existsSync(join(process.cwd(), 'pnpm-lock.yaml')) || existsSync(join(process.cwd(), 'pnpm-workspace.yaml'));
11+
} catch (e) {
12+
return false;
13+
}
14+
}
15+
616
module.exports = () => ({
717
title: 'Install',
818
task: () => new Listr(
@@ -19,9 +29,17 @@ module.exports = () => ({
1929
throwError(error);
2030
}))
2131
},
32+
{
33+
title: 'Installing dependencies using pnpm',
34+
enabled: () => hasPnpm() === false,
35+
task: () => {
36+
const args = ['install'];
37+
return exec('npm', args);
38+
}
39+
},
2240
{
2341
title: 'Installing dependencies using npm',
24-
enabled: () => hasYarn() === false,
42+
enabled: () => hasYarn() === false && hasPnpm() === false,
2543
task: () => {
2644
const args = ['install'];
2745
return exec('npm', args);

0 commit comments

Comments
 (0)