File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change 11const path = require ( 'path' )
2- const childProcess = require ( 'child_process' )
3- const { execSync } = childProcess
4-
2+ const http = require ( 'http' ) ;
53// upgrade logger
64function upgradeLogger ( ) {
75 const currPkg = require ( '../package.json' )
86 const cwd = path . resolve ( __dirname , '../' )
97 const pkgName = currPkg . name || 'mpvue-simple'
10- const pkg = JSON . parse ( execSync ( `curl \`npm config get registry\`${ pkgName } -s` , { cwd } ) )
11- const latestVesion = pkg [ 'dist-tags' ] . latest
128
13- if ( latestVesion !== currPkg . version ) {
14- console . log ( `${ pkgName } 有新版本 ${ latestVesion } 啦,请注意升级。\n例如: npm install ${ pkgName } -g\n` )
15- }
9+ http . get ( 'http://registry.npmjs.org/' + currPkg . name , ( res ) => {
10+ let rawData = '' ;
11+ res . on ( 'data' , ( chunk ) => rawData += chunk ) ;
12+ res . on ( 'end' , ( ) => {
13+ try {
14+ const parsedData = JSON . parse ( rawData ) ;
15+ let latestVesion = parsedData [ 'dist-tags' ] . latest ;
16+ if ( latestVesion !== currPkg . version ) {
17+ console . log ( `${ pkgName } 有新版本 ${ latestVesion } 啦,请注意升级。\n例如: npm install ${ pkgName } -g\n` )
18+ }
19+ } catch ( e ) {
20+ console . log ( e . message ) ;
21+ }
22+ } ) ;
23+ } )
1624}
1725
1826exports . upgradeLogger = upgradeLogger
You can’t perform that action at this time.
0 commit comments