Diff
checker
Texto
Texto
Imagens
Documentos
Excel
Pastas
Legal
Enterprise
Aplicativo para desktop
Preços
Fazer login
Baixar o Diffchecker Desktop
Comparar texto
Encontre a diferença entre dois arquivos de texto
Ferramentas
Histórico
Exibição
Layout
Dividido
Unificado
Editor live
Ocultar espaços em branco
Recolher inalteradas
Sem quebra de linha
Nível de detalhe
Inteligente
Sintaxe
Nenhum
Alterar aparência
Processamento
Ignorar
Transformar texto
Ir à primeira mudança
Editar entrada
Diffchecker Desktop
A maneira mais segura de usar o Diffchecker. Obtenha o aplicativo Diffchecker Desktop: seus diffs nunca saem do seu computador!
Obter Desktop
Untitled diff
Criado
há 9 anos
O diff nunca expira
Limpar
Exportar
Compartilhar
Explicar
2 remoções
Linhas
Total
Removido
Caracteres
Total
Removido
Para continuar usando este recurso, atualize para
Diff
checker
Pro
Ver preços
87 linhas
Copiar tudo
4 adições
Linhas
Total
Adicionado
Caracteres
Total
Adicionado
Para continuar usando este recurso, atualize para
Diff
checker
Pro
Ver preços
89 linhas
Copiar tudo
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;
};
};
Diferenças salvas
Texto original
Abrir arquivo
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 alterado
Abrir arquivo
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 Diferença