-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall.mjs
34 lines (30 loc) · 981 Bytes
/
install.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { execSync } from 'node:child_process';
// Function to check if the installed pnpm version is the latest
async function isPnpmLatest() {
try {
const installedVersion = execSync('pnpm -v').toString().trim();
const latestVersion = execSync('npm show pnpm version').toString().trim();
return installedVersion === latestVersion;
}
catch (error) {
console.error('Error checking pnpm version:', error);
return false;
}
}
// Main function to handle installation
async function install() {
try {
if (!(await isPnpmLatest())) {
console.log('pnpm is not the latest version. Please update pnpm.');
return;
}
console.log('Installing dependencies using pnpm...');
execSync('corepack use pnpm@`pnpm -v` && pnpm i', { stdio: 'inherit' });
console.log('Dependencies installed successfully.');
}
catch (error) {
console.error('Error installing dependencies:', error);
}
}
// Run the installation process
install();