@@ -10,16 +10,22 @@ console.log(`${chalk.blue('Downloading repository...')}`);
1010console . log ( '' ) ;
1111
1212const internalDir = path . resolve ( __dirname ) ;
13+ const baseDir = path . resolve ( __dirname , '..' ) ;
14+
15+ if ( ! fs . existsSync ( internalDir + '/.temp' ) ) {
16+ fs . mkdirSync ( internalDir + '/.temp' ) ;
17+ }
1318download ( 'Jake-Short/nextjs-docs-generator#main' , `${ internalDir } /.temp` , ( error ) => {
1419 if ( error ) {
1520 console . log ( `${ chalk . red . bold ( 'Error: ' ) } There was a problem downloading the repository. (${ error } )` ) ;
1621 console . log ( `Update aborted.` ) ;
1722 console . log ( '' ) ;
1823 }
1924 else {
20- let jsonData = JSON . parse ( fs . readFileSync ( `${ internalDir } /.temp/internal/info.json` , 'utf-8' ) ) ;
21- let version = jsonData . version ;
22- let currVersion = JSON . parse ( fs . readFileSync ( `${ internalDir } /info.json` , 'utf-8' ) ) . version ;
25+ let version = JSON . parse ( fs . readFileSync ( `${ internalDir } /.temp/package.json` , 'utf-8' ) ) . version ;
26+
27+ let currPackageContents = JSON . parse ( fs . readFileSync ( `${ baseDir } /package.json` , 'utf-8' ) ) ;
28+ let currVersion = JSON . parse ( fs . readFileSync ( `${ baseDir } /package.json` , 'utf-8' ) ) . version ;
2329
2430 if ( currVersion === version ) {
2531 console . log ( '' ) ;
@@ -71,11 +77,11 @@ download('Jake-Short/nextjs-docs-generator#main', `${internalDir}/.temp`, (error
7177 if ( res . Continue === true ) {
7278 // Trigger update
7379 if ( res . Continue === true ) {
74- const baseDir = path . resolve ( __dirname , '..' ) ;
75-
76- if ( ! fs . existsSync ( internalDir + '/.temp' ) ) {
77- fs . mkdirSync ( internalDir + '/.temp' ) ;
78- }
80+ // Update package.json version to new version
81+ currPackageContents . version = version ;
82+
83+ // Write new package.json into site folder
84+ fs . writeFileSync ( baseDir + '/package.json' , JSON . stringify ( currPackageContents , null , 4 ) ) ;
7985
8086 // Copy selected folders below
8187 if ( foldersToUpdate . includes ( 'internal' ) ) {
0 commit comments