Diff
checker
Texto
Texto
Imágenes
Documentos
Excel
Carpetas
Legal
Enterprise
Aplicación de escritorio
Precios
Iniciar sesión
Descargar Diffchecker Desktop
Comparar texto
Encuentra la diferencia entre dos archivos de texto
Herramientas
Historial
Visualización
Vista
Dividido
Unificado
Editor live
Ocultar espacios en blanco
Ocultar sin cambios
Sin ajuste de línea
Nivel de detalle
Inteligente
Sintaxis
Ninguno
Cambiar apariencia
Procesamiento
Ignorar
Transformar texto
Ir al primer cambio
Editar entrada
Diffchecker Desktop
La forma más segura de usar Diffchecker. ¡Obtén la app de Diffchecker Desktop: tus diffs nunca salen de tu computadora!
Obtener Desktop
Untitled diff
Creado
hace 9 años
El diff nunca expira
Borrar
Exportar
Compartir
Explicar
2 eliminaciones
Líneas
Total
Eliminado
Caracteres
Total
Eliminado
Para continuar usando esta función, actualice a
Diff
checker
Pro
Ver precios
87 líneas
Copiar todo
4 adiciones
Líneas
Total
Añadido
Caracteres
Total
Añadido
Para continuar usando esta función, actualice a
Diff
checker
Pro
Ver precios
89 líneas
Copiar todo
let fs = require('fs'),
let fs = require('fs'),
path = require('path'),
path = require('path'),
crypto = require('crypto'),
crypto = require('crypto'),
Stream = require('stream'),
Stream = require('stream'),
gutil = require('gulp-util'),
gutil = require('gulp-util'),
oncechecksums = {};
oncechecksums = {};
module.exports = function(options = {}) {
module.exports = function(options = {}) {
let stream = new Stream.Transform({objectMode: true}),
let stream = new Stream.Transform({objectMode: true}),
settings = {
settings = {
namespace: false,
namespace: false,
algorithm: 'sha1',
algorithm: 'sha1',
file: '.checksums',
file: '.checksums',
fileIndent: 4
fileIndent: 4
};
};
options = (typeof options === 'string') ? {namespace: options} : options;
options = (typeof options === 'string') ? {namespace: options} : options;
for (let key in options) {
for (let key in options) {
if (options.hasOwnProperty(key)) {
if (options.hasOwnProperty(key)) {
settings[key] = options[key];
settings[key] = options[key];
}
}
}
}
if (settings.file) {
if (settings.file) {
if (!fs.existsSync(settings.file)) {
if (!fs.existsSync(settings.file)) {
fs.writeFileSync(settings.file, JSON.stringify({}, null, settings.fileIndent));
fs.writeFileSync(settings.file, JSON.stringify({}, null, settings.fileIndent));
}
}
try {
try {
let content = fs.readFileSync(settings.file, 'utf8');
let content = fs.readFileSync(settings.file, 'utf8');
if (content) {
if (content) {
oncechecksums = JSON.parse(content);
oncechecksums = JSON.parse(content);
}
}
} catch (e) {
} catch (e) {
// go on about our business
// go on about our business
console.log(e);
console.log(e);
}
}
}
}
if (!!settings.namespace && !oncechecksums[settings.namespace]) {
if (!!settings.namespace && !oncechecksums[settings.namespace]) {
oncechecksums[settings.namespace] = {};
oncechecksums[settings.namespace] = {};
}
}
stream._transform = function(file, encoding, next) {
stream._transform = function(file, encoding, next) {
Copiar
Copiado
Copiar
Copiado
var flow = this;
if (file.isBuffer()) {
if (file.isBuffer()) {
let filename = path.basename(file.path),
let filename = path.basename(file.path),
filechecksum = crypto
filechecksum = crypto
.createHash(settings.algorithm || 'sha1')
.createHash(settings.algorithm || 'sha1')
.update(file.contents.toString('utf8'))
.update(file.contents.toString('utf8'))
.digest('hex');
.digest('hex');
if (settings.namespace in oncechecksums) {
if (settings.namespace in oncechecksums) {
if (oncechecksums[settings.namespace][filename] === filechecksum) {
if (oncechecksums[settings.namespace][filename] === filechecksum) {
return next();
return next();
}
}
oncechecksums[settings.namespace][filename] = filechecksum;
oncechecksums[settings.namespace][filename] = filechecksum;
} else {
} else {
if (oncechecksums[filename] === filechecksum) {
if (oncechecksums[filename] === filechecksum) {
return next();
return next();
}
}
oncechecksums[filename] = filechecksum;
oncechecksums[filename] = filechecksum;
}
}
if (settings.file) {
if (settings.file) {
fs.writeFile(settings.file, JSON.stringify(oncechecksums, null, settings.fileIndent), error => {
fs.writeFile(settings.file, JSON.stringify(oncechecksums, null, settings.fileIndent), error => {
if (error) {
if (error) {
return next(new gutil.PluginError('gulp-once', error, {showStack: true}));
return next(new gutil.PluginError('gulp-once', error, {showStack: true}));
}
}
});
});
}
}
Copiar
Copiado
Copiar
Copiado
return next(null, file);
}
}
Copiar
Copiado
Copiar
Copiado
flow.push(file);
return next();
};
};
return stream;
return stream;
};
};
Diferencias guardadas
Texto original
Abrir archivo
let fs = require('fs'), path = require('path'), crypto = require('crypto'), Stream = require('stream'), gutil = require('gulp-util'), oncechecksums = {}; module.exports = function(options = {}) { let stream = new Stream.Transform({objectMode: true}), settings = { namespace: false, algorithm: 'sha1', file: '.checksums', fileIndent: 4 }; options = (typeof options === 'string') ? {namespace: options} : options; for (let key in options) { if (options.hasOwnProperty(key)) { settings[key] = options[key]; } } if (settings.file) { if (!fs.existsSync(settings.file)) { fs.writeFileSync(settings.file, JSON.stringify({}, null, settings.fileIndent)); } try { let content = fs.readFileSync(settings.file, 'utf8'); if (content) { oncechecksums = JSON.parse(content); } } catch (e) { // go on about our business console.log(e); } } if (!!settings.namespace && !oncechecksums[settings.namespace]) { oncechecksums[settings.namespace] = {}; } stream._transform = function(file, encoding, next) { if (file.isBuffer()) { let filename = path.basename(file.path), filechecksum = crypto .createHash(settings.algorithm || 'sha1') .update(file.contents.toString('utf8')) .digest('hex'); if (settings.namespace in oncechecksums) { if (oncechecksums[settings.namespace][filename] === filechecksum) { return next(); } oncechecksums[settings.namespace][filename] = filechecksum; } else { if (oncechecksums[filename] === filechecksum) { return next(); } oncechecksums[filename] = filechecksum; } if (settings.file) { fs.writeFile(settings.file, JSON.stringify(oncechecksums, null, settings.fileIndent), error => { if (error) { return next(new gutil.PluginError('gulp-once', error, {showStack: true})); } }); } return next(null, file); } }; return stream; };
Texto modificado
Abrir archivo
let fs = require('fs'), path = require('path'), crypto = require('crypto'), Stream = require('stream'), gutil = require('gulp-util'), oncechecksums = {}; module.exports = function(options = {}) { let stream = new Stream.Transform({objectMode: true}), settings = { namespace: false, algorithm: 'sha1', file: '.checksums', fileIndent: 4 }; options = (typeof options === 'string') ? {namespace: options} : options; for (let key in options) { if (options.hasOwnProperty(key)) { settings[key] = options[key]; } } if (settings.file) { if (!fs.existsSync(settings.file)) { fs.writeFileSync(settings.file, JSON.stringify({}, null, settings.fileIndent)); } try { let content = fs.readFileSync(settings.file, 'utf8'); if (content) { oncechecksums = JSON.parse(content); } } catch (e) { // go on about our business console.log(e); } } if (!!settings.namespace && !oncechecksums[settings.namespace]) { oncechecksums[settings.namespace] = {}; } stream._transform = function(file, encoding, next) { var flow = this; if (file.isBuffer()) { let filename = path.basename(file.path), filechecksum = crypto .createHash(settings.algorithm || 'sha1') .update(file.contents.toString('utf8')) .digest('hex'); if (settings.namespace in oncechecksums) { if (oncechecksums[settings.namespace][filename] === filechecksum) { return next(); } oncechecksums[settings.namespace][filename] = filechecksum; } else { if (oncechecksums[filename] === filechecksum) { return next(); } oncechecksums[filename] = filechecksum; } if (settings.file) { fs.writeFile(settings.file, JSON.stringify(oncechecksums, null, settings.fileIndent), error => { if (error) { return next(new gutil.PluginError('gulp-once', error, {showStack: true})); } }); } } flow.push(file); return next(); }; return stream; };
Encontrar la diferencia