@@ -138,44 +138,46 @@ async function dev() {
138
138
spawn . sync ( 'npx' , [ 'vite' , '--open' ] , { stdio : 'inherit' } )
139
139
140
140
async function installDependencies ( ) {
141
- console . log ( cyan ( 'Checking pnpm version...' ) )
142
- const latestPNPMVersion = spawn . sync ( 'npm' , [ 'view' , 'pnpm' , 'version' ] ) . stdout . toString ( ) . trim ( )
143
- const currentPNPMVersion = spawn . sync ( 'pnpm' , [ '-v' ] ) . stdout . toString ( ) . trim ( )
144
- // Mac 自带 curl,Linux 不一定,Windows 不支持指定 pnpm 版本
145
- if ( latestPNPMVersion !== currentPNPMVersion && [ 'darwin' , 'linux' ] . includes ( process . platform ) ) {
146
- console . log ( cyan ( 'Upgrading pnpm...' ) )
147
- try {
148
- console . log ( execSync ( `curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=${ latestPNPMVersion } sh -` ) . toString ( ) )
149
- /* const curlProcess = spawn.sync('curl', ['-fsSL', 'https://get.pnpm.io/install.sh'], {
150
- env: { PNPM_VERSION: latestPNPMVersion },
151
- stdio: ['pipe', 'pipe', 'pipe'], // Redirect stdin, stdout, and stderr
152
- })
153
- if (curlProcess.status === 0) {
154
- // If curl was successful, execute the shell command
155
- const shCommand = 'sh'
156
- const shArgs = ['-']
157
-
158
- const shProcess = spawn.sync(shCommand, shArgs, {
159
- input: curlProcess.stdout, // Pass the stdout of curl as input to sh
160
- stdio: ['pipe', 'inherit', 'inherit'], // Redirect stdin, inherit stdout and stderr
141
+ if ( [ 'darwin' , 'linux' ] . includes ( process . platform ) ) {
142
+ console . log ( cyan ( 'Checking pnpm version...' ) )
143
+ const latestPNPMVersion = spawn . sync ( 'npm' , [ 'view' , 'pnpm' , 'version' ] ) . stdout . toString ( ) . trim ( )
144
+ const currentPNPMVersion = spawn . sync ( 'pnpm' , [ '-v' ] ) . stdout . toString ( ) . trim ( )
145
+ // Mac 自带 curl,Linux 不一定,Windows 不支持指定 pnpm 版本
146
+ if ( latestPNPMVersion !== currentPNPMVersion ) {
147
+ console . log ( cyan ( 'Upgrading pnpm...' ) )
148
+ try {
149
+ console . log ( execSync ( `curl -fsSL https://get.pnpm.io/install.sh | env PNPM_VERSION=${ latestPNPMVersion } sh -` ) . toString ( ) )
150
+ /* const curlProcess = spawn.sync('curl', ['-fsSL', 'https://get.pnpm.io/install.sh'], {
151
+ env: { PNPM_VERSION: latestPNPMVersion },
152
+ stdio: ['pipe', 'pipe', 'pipe'], // Redirect stdin, stdout, and stderr
161
153
})
162
-
163
- if (shProcess.status === 0) {
164
- console.log('pnpm installation successful.')
154
+ if (curlProcess.status === 0) {
155
+ // If curl was successful, execute the shell command
156
+ const shCommand = 'sh'
157
+ const shArgs = ['-']
158
+
159
+ const shProcess = spawn.sync(shCommand, shArgs, {
160
+ input: curlProcess.stdout, // Pass the stdout of curl as input to sh
161
+ stdio: ['pipe', 'inherit', 'inherit'], // Redirect stdin, inherit stdout and stderr
162
+ })
163
+
164
+ if (shProcess.status === 0) {
165
+ console.log('pnpm installation successful.')
166
+ } else {
167
+ console.error('pnpm installation failed.')
168
+ }
165
169
} else {
166
- console.error('pnpm installation failed.')
167
- }
168
- } else {
169
- console.error('curl command failed.')
170
- } */
171
- console . log ( cyan ( 'Setting registry...' ) )
172
- spawn . sync ( 'pnpm' , [ 'config' , 'set' , 'registry' , 'https://registry.npmmirror.com' ] , { stdio : 'inherit' } )
173
- console . log ( cyan ( 'Installing node lts...' ) )
174
- spawn . sync ( 'pnpm' , [ 'env' , 'use' , '-g' , 'lts' ] , { stdio : 'inherit' } )
175
- console . log ( cyan ( 'Installing global packages...' ) )
176
- spawn . sync ( 'pnpm' , [ 'add' , 'cnpm' , '@antfu/ni' , 'only-allow' , '-g' ] , { stdio : 'inherit' } )
177
- } catch ( e ) {
170
+ console.error('curl command failed.')
171
+ } */
172
+ console . log ( cyan ( 'Setting registry...' ) )
173
+ spawn . sync ( 'pnpm' , [ 'config' , 'set' , 'registry' , 'https://registry.npmmirror.com' ] , { stdio : 'inherit' } )
174
+ console . log ( cyan ( 'Installing node lts...' ) )
175
+ spawn . sync ( 'pnpm' , [ 'env' , 'use' , '-g' , 'lts' ] , { stdio : 'inherit' } )
176
+ console . log ( cyan ( 'Installing global packages...' ) )
177
+ spawn . sync ( 'pnpm' , [ 'add' , 'cnpm' , '@antfu/ni' , 'only-allow' , '-g' ] , { stdio : 'inherit' } )
178
+ } catch ( e ) {
178
179
180
+ }
179
181
}
180
182
}
181
183
console . log ( cyan ( 'Upgrading dependencies...' ) )
0 commit comments