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-flatten/lib/flatten-path.js
var path = require('path');

function includeParents(dirs, opts) {
  var topLevels;
  var bottomLevels = 0;
  var topPath = [];
  var bottomPath = [];
  var newPath = [];

  if (Array.isArray(opts)) {
    topLevels = Math.abs(opts[0]);
    bottomLevels = Math.abs(opts[1]);
  } else if (opts >= 0) {
    topLevels = opts;
  } else {
    bottomLevels = Math.abs(opts);
  }

  if (topLevels + bottomLevels > dirs.length) {
    return dirs;
  }

  while (topLevels > 0) {
    topPath.push(dirs.shift());
    topLevels--;
  }
  while (bottomLevels > 0) {
    bottomPath.unshift(dirs.pop());
    bottomLevels--;
  }
  return topPath.concat(bottomPath);
}

function subPath(dirs, opts) {
  if (Array.isArray(opts)) {
    return dirs.slice(opts[0], opts[1]);
  } else {
    return dirs.slice(opts);
  }
}

/**
 * Flatten the path to the desired depth
 *
 * @param {File} file - vinyl file
 * @param {Object} options
 * @return {String}
 */
function flattenPath(file, opts) {
  var fileName = path.basename(file.path);
  var dirs;

  if (!opts.includeParents && !opts.subPath) {
    return fileName;
  }

  dirs = path.dirname(file.relative).split(path.sep);
  if (opts.includeParents) {
    dirs = includeParents(dirs, opts.includeParents);
  }
  if (opts.subPath) {
    dirs = subPath(dirs, opts.subPath);
  }

  dirs.push(fileName);
  return path.join.apply(path, dirs);
}

module.exports = flattenPath