install.js
function downloadPhantomjs() {
  var downloadSpec = getDownloadSpec()
  if (!downloadSpec) {
    console.error(
        'Unexpected platform or architecture: ' + getTargetPlatform() + '/' + getTargetArch() + '\n' +
        'It seems there is no binary available for your platform/architecture\n' +
        'Try to install PhantomJS globally')
    exit(1)
  }

  var downloadUrl = downloadSpec.url
  var downloadedFile

  return Q.fcall(function () {
    // Can't use a global version so start a download.
    var tmpPath = findSuitableTempDirectory()
    var fileName = downloadUrl.split('/').pop()
    downloadedFile = path.join(tmpPath, fileName)

    if (fs.existsSync(downloadedFile)) {
      console.log('Download already available at', downloadedFile)
      return verifyChecksum(downloadedFile, downloadSpec.checksum)
    }
    return false
  }).then(function (verified) {
    if (verified) {
      return downloadedFile
    }

    // Start the install.
    console.log('Downloading', downloadUrl)
    console.log('Saving to', downloadedFile)
    return requestBinary(getRequestOptions(), downloadedFile)
  })
}
function downloadPhantomjs() {
  var downloadSpec = getDownloadSpec()
  if (!downloadSpec) {
    console.error(
        'Unexpected platform or architecture: ' + getTargetPlatform() + '/' + getTargetArch() + '\n' +
        'It seems there is no binary available for your platform/architecture\n' +
        'Try to install PhantomJS globally')
    exit(1)
  }

  var downloadUrl = downloadSpec.url
  var downloadedFile

  return Q.fcall(function () {
    // Can't use a global version so start a download.
    var tmpPath = findSuitableTempDirectory()
    var fileName = downloadUrl.split('/').pop()
    downloadedFile = path.join(tmpPath, fileName)

    if (fs.existsSync(downloadedFile)) {
      console.log('Download already available at', downloadedFile)
      return verifyChecksum(downloadedFile, downloadSpec.checksum)
    }
    return false
  }).then(function (verified) {
    if (verified) {
      return downloadedFile
    }

    // Start the install.
    console.log('Downloading', downloadUrl)
    console.log('Saving to', downloadedFile)
    return requestBinary(getRequestOptions(), downloadedFile)
  })
}
function downloadPhantomjs ( ) { var downloadSpec = getDownloadSpec ( ) if ( ! downloadSpec ) { console . error ( 'Unexpected platform or architecture: ' + getTargetPlatform ( ) + '/' + getTargetArch ( ) + '\n' + 'It seems there is no binary available for your platform/architecture\n' + 'Try to install PhantomJS globally' ) exit ( 1 ) } var downloadUrl = downloadSpec . url var downloadedFile return Q . fcall ( function ( ) { // Can't use a global version so start a download. var tmpPath = findSuitableTempDirectory ( ) var fileName = downloadUrl . split ( '/' ) . pop ( ) downloadedFile = path . join ( tmpPath , fileName ) if ( fs . existsSync ( downloadedFile ) ) { console . log ( 'Download already available at' , downloadedFile ) return verifyChecksum ( downloadedFile , downloadSpec . checksum ) } return false } ) . then ( function ( verified ) { if ( verified ) { return downloadedFile } // Start the install. console . log ( 'Downloading' , downloadUrl ) console . log ( 'Saving to' , downloadedFile ) return requestBinary ( getRequestOptions ( ) , downloadedFile ) } ) }
Download phantomjs, reusing the existing copy on disk if available.
Exits immediately if there is no binary to download.
@return {Promise.<string>} The path to the downloaded file.
Download phantomjs reusing the existing copy on disk if available . Exits immediately if there is no binary to download .