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: //proc/1526/task/1530/cwd/zaklada/html/node_modules/gulp-changed/index.js
'use strict';
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const gutil = require('gulp-util');
const through = require('through2');

// Ignore missing file error
function fsOperationFailed(stream, sourceFile, err) {
	if (err) {
		if (err.code !== 'ENOENT') {
			stream.emit('error', new gutil.PluginError('gulp-changed', err, {
				fileName: sourceFile.path
			}));
		}

		stream.push(sourceFile);
	}

	return err;
}

const sha1 = buf => crypto.createHash('sha1').update(buf).digest('hex');

// Only push through files changed more recently than the destination files
function compareLastModifiedTime(stream, cb, sourceFile, targetPath) {
	fs.stat(targetPath, (err, targetStat) => {
		if (!fsOperationFailed(stream, sourceFile, err)) {
			if (sourceFile.stat && sourceFile.stat.mtime > targetStat.mtime) {
				stream.push(sourceFile);
			}
		}

		cb();
	});
}

// Only push through files with different SHA1 than the destination files
function compareSha1Digest(stream, cb, sourceFile, targetPath) {
	fs.readFile(targetPath, (err, targetData) => {
		if (sourceFile.isNull()) {
			cb(null, sourceFile);
			return;
		}

		if (!fsOperationFailed(stream, sourceFile, err)) {
			const sourceDigest = sha1(sourceFile.contents);
			const targetDigest = sha1(targetData);

			if (sourceDigest !== targetDigest) {
				stream.push(sourceFile);
			}
		}

		cb();
	});
}

module.exports = (dest, opts) => {
	opts = Object.assign({
		cwd: process.cwd(),
		hasChanged: compareLastModifiedTime
	}, opts);

	if (!dest) {
		throw new gutil.PluginError('gulp-changed', '`dest` required');
	}

	if (opts.transformPath !== undefined && typeof opts.transformPath !== 'function') {
		throw new gutil.PluginError('gulp-changed', '`opts.transformPath` needs to be a function');
	}

	return through.obj(function (file, enc, cb) {
		const dest2 = typeof dest === 'function' ? dest(file) : dest;
		let newPath = path.resolve(opts.cwd, dest2, file.relative);

		if (opts.extension) {
			newPath = gutil.replaceExtension(newPath, opts.extension);
		}

		if (opts.transformPath) {
			newPath = opts.transformPath(newPath);

			if (typeof newPath !== 'string') {
				throw new gutil.PluginError('gulp-changed', '`opts.transformPath` needs to return a string');
			}
		}

		opts.hasChanged(this, cb, file, newPath);
	});
};

module.exports.compareLastModifiedTime = compareLastModifiedTime;
module.exports.compareSha1Digest = compareSha1Digest;