@@ -96,21 +96,24 @@ function isExclude(extension) {
9696
9797function getBuildLog ( ) {
9898 if ( fs . existsSync ( logfile ) ) {
99- return JSON . parse ( fs . readFileSync ( logfile ) )
99+ const str = fs . readFileSync ( logfile ) . toString ( 'utf-8' )
100+ return JSON . parse ( str )
100101 }
101102 fs . writeFileSync ( logfile , '{}' )
102103 return { }
103104}
104105
105- function shouldUpdate ( package , lasttime ) {
106+ function shouldUpdate ( extension , package , lasttime ) {
106107 let buildHistory = getBuildLog ( )
107- if ( ! buildHistory [ package ] ) {
108- buildHistory [ package ] = lasttime
108+ if ( ! buildHistory [ extension ] ) {
109+ buildHistory [ extension ] = lasttime
109110 fs . writeFileSync ( logfile , JSON . stringify ( buildHistory ) )
111+ console . info ( 'scan' , package )
110112 return true
111113 }
112- if ( buildHistory [ package ] === lasttime ) return false
113- buildHistory [ package ] = lasttime
114+ if ( buildHistory [ extension ] === lasttime ) return false
115+ buildHistory [ extension ] = lasttime
116+ console . info ( package , 'will be update' )
114117 fs . writeFileSync ( logfile , JSON . stringify ( buildHistory ) )
115118 return true
116119}
@@ -122,7 +125,7 @@ function parseExtensions() {
122125 if ( isExclude ( extension ) || ! stat || stat . isFile ( ) ) continue
123126 const packagePath = path . join ( __dirname , './extensions/' + extension + '/package.json' )
124127 const stime = stat . mtime / 1000
125- if ( shouldUpdate ( packagePath , stime ) ) {
128+ if ( shouldUpdate ( extension , packagePath , stime ) ) {
126129 const pack = fs . readFileSync ( packagePath , 'utf-8' )
127130 const jsn = JSON . parse ( pack )
128131 for ( let name in jsn [ 'dependencies' ] ) {
@@ -143,9 +146,13 @@ function parseExtensions() {
143146
144147function installDependencies ( ) {
145148 for ( let name in installPackages ) {
146- if ( fs . existsSync ( path . resolve ( __dirname , './extensions/node_modules/' + name ) ) ) {
147- const stat = fs . statSync ( path . resolve ( __dirname , './extensions/node_modules/' + name ) )
148- if ( stat . isFile ( ) || stat . isDirectory ( ) ) continue
149+ const filepath = path . resolve ( __dirname , './extensions/node_modules/' + name )
150+ if ( fs . existsSync ( filepath ) ) {
151+ const stat = fs . statSync ( filepath )
152+ if ( stat . isFile ( ) || stat . isDirectory ( ) ) {
153+ console . info ( 'file' , filepath , 'exist' )
154+ continue
155+ }
149156 }
150157 console . info ( `install ${ name } @${ installPackages [ name ] } ` )
151158 runCommand ( 'npm install --prefix extensions ' + name + '@' + installPackages [ name ] )
0 commit comments