HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/zaklada/html/node_modules/gulp-cache/index.js
'use strict';

var Cache = require('cache-swap');
var File = require('vinyl');
var objectAssign = require('object-assign');
var objectOmit = require('object.omit');
var objectPick = require('object.pick');
var PluginError = require('gulp-util').PluginError;
var TaskProxy = require('./lib/TaskProxy');
var Transform = require('readable-stream/transform');

var VERSION = require('./package.json').version;
var fileCache = new Cache({cacheDirName: 'gulp-cache'});

function defaultKey(file) {
  return [VERSION, file.contents.toString('base64')].join('');
}

var defaultOptions = {
  fileCache: fileCache,
  name: 'default',
  key: defaultKey,
  restore: function(restored) {
    if (restored.contents) {
      // Handle node 0.11 buffer to JSON as object with { type: 'buffer', data: [...] }
      if (restored && restored.contents && Array.isArray(restored.contents.data)) {
        restored.contents = new Buffer(restored.contents.data);
      } else if (Array.isArray(restored.contents)) {
        restored.contents = new Buffer(restored.contents);
      } else if (typeof restored.contents === 'string') {
        restored.contents = new Buffer(restored.contents, 'base64');
      }
    }

    var restoredFile = new File(restored);
    var extraTaskProperties = objectOmit(restored, Object.keys(restoredFile));

    // Restore any properties that the original task put on the file;
    // but omit the normal properties of the file
    return objectAssign(restoredFile, extraTaskProperties);
  },
  success: true,
  value: function(file) {
    // Convert from a File object (from vinyl) into a plain object
    return objectPick(file, ['cwd', 'base', 'contents', 'stat', 'history', 'path']);
  }
};

var cacheTask = function(task, opts) {
  // Check for required task option
  if (!task) {
    throw new PluginError('gulp-cache', 'Must pass a task to cache()');
  }

  // Check if this task participates in the cacheable contract
  if (task.cacheable) {
    // Use the cacheable options, but allow the user to override them
    opts = objectAssign({}, task.cacheable, opts);
  }

  // Make sure we have some sane defaults
  opts = objectAssign({}, cacheTask.defaultOptions, opts);

  return new Transform({
    objectMode: true,
    transform: function(file, enc, cb) {
      if (file.isNull()) {
        cb(null, file);
        return;
      }

      if (file.isStream()) {
        cb(new PluginError('gulp-cache', 'Cannot operate on stream sources'));
        return;
      }

      new TaskProxy({
        task: task,
        file: file,
        opts: opts
      })
      .processFile().then(function(result) {
        cb(null, result);
      }, function(err) {
        cb(new PluginError('gulp-cache', err));
      });
    }
  });
};

cacheTask.clear = function(opts) {
  opts = objectAssign({}, cacheTask.defaultOptions, opts);

  return new Transform({
    objectMode: true,
    transform: function(file, enc, cb) {
      if (file.isNull()) {
        cb(null, file);
        return;
      }

      if (file.isStream()) {
        cb(new PluginError('gulp-cache', 'Cannot operate on stream sources'));
        return;
      }

      var taskProxy = new TaskProxy({
        task: null,
        file: file,
        opts: opts
      });

      taskProxy.removeCachedResult().then(function() {
        cb(null, file);
      }).catch(function(err) {
        cb(new PluginError('gulp-cache', err));
      });
    }
  });
};

cacheTask.clearAll = function(done) {
  fileCache.clear(null, function(err) {
    if (err) {
      var pluginError = new PluginError(
        'gulp-cache',
        'Problem clearing the cache: ' + err.message
      );

      if (done) {
        done(pluginError);
        return;
      }

      throw pluginError;
    }

    if (done) {
      done();
    }
  });
};

cacheTask.fileCache = fileCache;
cacheTask.defaultOptions = defaultOptions;
cacheTask.Cache = Cache;

module.exports = cacheTask;