scripts/preparePackages.js
function updateVersion(pkg) {
  fs.readFile(__dirname + '/../package.json', 'utf8', (err, data) => {
    errorOnFail(err)
    const globalVersion = JSON.parse(data).version

    fs.readFile(__dirname + '/../packages/' + pkg + '/package.json', (err, data) => {
      errorOnFail(err)

      const packageJSON = JSON.parse(data)
      packageJSON.version = globalVersion

      // Update react-look-core dependency version
      if (pkg !== 'react-look-core') {
        packageJSON.dependencies['react-look-core'] = '^' + globalVersion
      }

      // Update react-look dependency version
      if (pkg === 'react-look-test-utils') {
        packageJSON.peerDependencies['react-look'] = '^' + globalVersion
      }

      const newPackageJSON = JSON.stringify(packageJSON, null, 4)

      fs.writeFile(__dirname + '/../packages/' + pkg + '/package.json', newPackageJSON, err => {
        errorOnFail(err)
        console.log('Successfully updated ' + pkg + ' version and react-look-core dependency version to ' + globalVersion + '.')
      })
    })
  })
}
function updateVersion(pkg) {
  fs.readFile(__dirname + '/../package.json', 'utf8', (err, data) => {
    errorOnFail(err)
    const globalVersion = JSON.parse(data).version

    fs.readFile(__dirname + '/../packages/' + pkg + '/package.json', (err, data) => {
      errorOnFail(err)

      const packageJSON = JSON.parse(data)
      packageJSON.version = globalVersion

      // Update react-look-core dependency version
      if (pkg !== 'react-look-core') {
        packageJSON.dependencies['react-look-core'] = '^' + globalVersion
      }

      // Update react-look dependency version
      if (pkg === 'react-look-test-utils') {
        packageJSON.peerDependencies['react-look'] = '^' + globalVersion
      }

      const newPackageJSON = JSON.stringify(packageJSON, null, 4)

      fs.writeFile(__dirname + '/../packages/' + pkg + '/package.json', newPackageJSON, err => {
        errorOnFail(err)
        console.log('Successfully updated ' + pkg + ' version and react-look-core dependency version to ' + globalVersion + '.')
      })
    })
  })
}
function updateVersion ( pkg ) { fs . readFile ( __dirname + '/../package.json' , 'utf8' , ( err , data ) => { errorOnFail ( err ) const globalVersion = JSON . parse ( data ) . version fs . readFile ( __dirname + '/../packages/' + pkg + '/package.json' , ( err , data ) => { errorOnFail ( err ) const packageJSON = JSON . parse ( data ) packageJSON . version = globalVersion // Update react-look-core dependency version if ( pkg !== 'react-look-core' ) { packageJSON . dependencies [ 'react-look-core' ] = '^' + globalVersion } // Update react-look dependency version if ( pkg === 'react-look-test-utils' ) { packageJSON . peerDependencies [ 'react-look' ] = '^' + globalVersion } const newPackageJSON = JSON . stringify ( packageJSON , null , 4 ) fs . writeFile ( __dirname + '/../packages/' + pkg + '/package.json' , newPackageJSON , err => { errorOnFail ( err ) console . log ( 'Successfully updated ' + pkg + ' version and react-look-core dependency version to ' + globalVersion + '.' ) } ) } ) } ) }
Updates the package.json version of a given pkg with the global package.json version
Updates the package . json version of a given pkg with the global package . json version