@@ -10,6 +10,13 @@ const debug = require('debug')('update-check')
1010const hook : Hook < 'init' > = async function ( { config} ) {
1111 const file = path . join ( config . cacheDir , 'version' )
1212
13+ // Destructure package.json configuration with defaults
14+ const {
15+ timeoutInDays = 60 ,
16+ registry = 'https://registry.npmjs.org' ,
17+ authorization = '' ,
18+ } = ( config . pjson . oclif as any ) [ 'warn-if-update-available' ] || { }
19+
1320 const checkVersion = async ( ) => {
1421 try {
1522 const distTags = await fs . readJSON ( file )
@@ -28,8 +35,6 @@ const hook: Hook<'init'> = async function ({config}) {
2835
2936 const refreshNeeded = async ( ) => {
3037 try {
31- const cfg = ( config . pjson . oclif as any ) [ 'warn-if-update-available' ] || { }
32- const timeoutInDays = cfg . timeoutInDays || 60
3338 const { mtime} = await fs . stat ( file )
3439 const staleAt = new Date ( mtime . valueOf ( ) + 1000 * 60 * 60 * 24 * timeoutInDays )
3540 return staleAt < new Date ( )
@@ -43,7 +48,7 @@ const hook: Hook<'init'> = async function ({config}) {
4348 debug ( 'spawning version refresh' )
4449 spawn (
4550 process . execPath ,
46- [ path . join ( __dirname , '../../../lib/get-version' ) , config . name , file , config . version ] ,
51+ [ path . join ( __dirname , '../../../lib/get-version' ) , config . name , file , config . version , registry , authorization ] ,
4752 {
4853 detached : ! config . windows ,
4954 stdio : 'ignore' ,
0 commit comments