function checkAndDownloadBinary() {
  if (process.env.SKIP_SASS_BINARY_DOWNLOAD_FOR_CI) {
    console.log('Skipping downloading binaries on CI builds');
    return;
  }

  var cachedBinary = sass.getCachedBinary(),
    cachePath = sass.getBinaryCachePath(),
    binaryPath = sass.getBinaryPath();

  if (sass.hasBinary(binaryPath)) {
    console.log('node-sass build', 'Binary found at', binaryPath);
    return;
  }

  try {
    mkdir.sync(path.dirname(binaryPath));
  } catch (err) {
    console.error('Unable to save binary', path.dirname(binaryPath), ':', err);
    return;
  }

  if (cachedBinary) {
    console.log('Cached binary found at', cachedBinary);
    fs.createReadStream(cachedBinary).pipe(fs.createWriteStream(binaryPath));
    return;
  }

  download(sass.getBinaryUrl(), binaryPath, function(err) {
    if (err) {
      console.error(err);
      return;
    }

    console.log('Binary saved to', binaryPath);

    cachedBinary = path.join(cachePath, sass.getBinaryName());

    if (cachePath) {
      console.log('Caching binary to', cachedBinary);

      try {
        mkdir.sync(path.dirname(cachedBinary));
        fs.createReadStream(binaryPath)
          .pipe(fs.createWriteStream(cachedBinary))
          .on('error', function (err) {
            console.log('Failed to cache binary:', err);
          });
      } catch (err) {
        console.log('Failed to cache binary:', err);
      }
    }
  });
}
function checkAndDownloadBinary() {
  if (process.env.SKIP_SASS_BINARY_DOWNLOAD_FOR_CI) {
    console.log('Skipping downloading binaries on CI builds');
    return;
  }

  var cachedBinary = sass.getCachedBinary(),
    cachePath = sass.getBinaryCachePath(),
    binaryPath = sass.getBinaryPath();

  if (sass.hasBinary(binaryPath)) {
    console.log('node-sass build', 'Binary found at', binaryPath);
    return;
  }

  try {
    mkdir.sync(path.dirname(binaryPath));
  } catch (err) {
    console.error('Unable to save binary', path.dirname(binaryPath), ':', err);
    return;
  }

  if (cachedBinary) {
    console.log('Cached binary found at', cachedBinary);
    fs.createReadStream(cachedBinary).pipe(fs.createWriteStream(binaryPath));
    return;
  }

  download(sass.getBinaryUrl(), binaryPath, function(err) {
    if (err) {
      console.error(err);
      return;
    }

    console.log('Binary saved to', binaryPath);

    cachedBinary = path.join(cachePath, sass.getBinaryName());

    if (cachePath) {
      console.log('Caching binary to', cachedBinary);

      try {
        mkdir.sync(path.dirname(cachedBinary));
        fs.createReadStream(binaryPath)
          .pipe(fs.createWriteStream(cachedBinary))
          .on('error', function (err) {
            console.log('Failed to cache binary:', err);
          });
      } catch (err) {
        console.log('Failed to cache binary:', err);
      }
    }
  });
}
function checkAndDownloadBinary ( ) { if ( process . env . SKIP_SASS_BINARY_DOWNLOAD_FOR_CI ) { console . log ( 'Skipping downloading binaries on CI builds' ) ; return ; } var cachedBinary = sass . getCachedBinary ( ) , cachePath = sass . getBinaryCachePath ( ) , binaryPath = sass . getBinaryPath ( ) ; if ( sass . hasBinary ( binaryPath ) ) { console . log ( 'node-sass build' , 'Binary found at' , binaryPath ) ; return ; } try { mkdir . sync ( path . dirname ( binaryPath ) ) ; } catch ( err ) { console . error ( 'Unable to save binary' , path . dirname ( binaryPath ) , ':' , err ) ; return ; } if ( cachedBinary ) { console . log ( 'Cached binary found at' , cachedBinary ) ; fs . createReadStream ( cachedBinary ) . pipe ( fs . createWriteStream ( binaryPath ) ) ; return ; } download ( sass . getBinaryUrl ( ) , binaryPath , function ( err ) { if ( err ) { console . error ( err ) ; return ; } console . log ( 'Binary saved to' , binaryPath ) ; cachedBinary = path . join ( cachePath , sass . getBinaryName ( ) ) ; if ( cachePath ) { console . log ( 'Caching binary to' , cachedBinary ) ; try { mkdir . sync ( path . dirname ( cachedBinary ) ) ; fs . createReadStream ( binaryPath ) . pipe ( fs . createWriteStream ( cachedBinary ) ) . on ( 'error' , function ( err ) { console . log ( 'Failed to cache binary:' , err ) ; } ) ; } catch ( err ) { console . log ( 'Failed to cache binary:' , err ) ; } } } ) ; }
Check and download binary

@api private
Check and download binary
Check if binary exists and download it