Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

diff2html-cli

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diff2html-cli - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0-windows1

8

package.json
{
"name": "diff2html-cli",
"version": "1.3.0",
"version": "1.4.0-windows1",
"homepage": "https://www.github.com/rtfpessoa/diff2html-cli",

@@ -48,6 +48,8 @@ "description": "Fast Diff to colorized HTML",

"dependencies": {
"yargs": "^3.31.0",
"copy-paste": "^1.1.4",
"diff2html": "~1.2.0",
"extend": "^3.0.0",
"open": "^0.0.5",
"request": "^2.67.0",
"diff2html": "~1.2.0"
"yargs": "^3.31.0"
},

@@ -54,0 +56,0 @@ "devDependencies": {

@@ -50,3 +50,3 @@ # diff2html-cli

sudo npm install -g diff2html-cli
npm install -g diff2html-cli

@@ -53,0 +53,0 @@ ## Usage

@@ -10,2 +10,5 @@ /*

var os = require('os');
var path = require('path');
var diff2Html = require('diff2html').Diff2Html;

@@ -17,2 +20,5 @@

var open = require('open');
var ncp = require("copy-paste");
function Diff2HtmlInterface() {

@@ -46,3 +52,3 @@ }

} else {
gitArgs = '-M HEAD~1';
gitArgs = '-M HEAD';
}

@@ -89,10 +95,12 @@

Diff2HtmlInterface.prototype._prepareHTML = function(content) {
var template = utils.readFileSync(__dirname + '/../dist/template.html');
var templatePath = path.resolve(__dirname, '..', 'dist', 'template.html');
var template = utils.readFileSync(templatePath);
var cssFile = __dirname + '/../node_modules/diff2html/css/diff2html.css';
var cssFallbackFile = __dirname + '/../dist/diff2html.css';
if (utils.existsSync(cssFile)) cssFile = cssFallbackFile;
var cssFilePath = path.resolve(__dirname, '..', 'node_modules', 'diff2html', 'css', 'diff2html.css');
var cssFallbackPath = path.resolve(__dirname, '..', 'dist', 'diff2html.css');
var cssContent = utils.readFileSync(cssFile);
if (!utils.existsSync(cssFilePath)) cssFilePath = cssFallbackPath;
var cssContent = utils.readFileSync(cssFilePath);
return template

@@ -108,8 +116,9 @@ .replace('<!--css-->', '<style>\n' + cssContent + '\n</style>')

Diff2HtmlInterface.prototype.preview = function(content, format) {
var filePath = '/tmp/diff.' + format;
var filename = 'diff.' + format;
var filePath = path.resolve(os.tmpdir(), filename);
utils.writeFile(filePath, content);
utils.runCmd('open ' + filePath);
open(filePath);
};
Diff2HtmlInterface.prototype.postToDiffy = function(diff, postType) {
Diff2HtmlInterface.prototype.postToDiffy = function(diff, postType, callback) {
var jsonParams = {udiff: diff};

@@ -128,5 +137,8 @@

if (postType === 'browser') {
utils.runCmd('open ' + response.url);
open(response.url);
return callback(null, response.url);
} else if (postType === 'pbcopy') {
utils.runCmd('echo "' + response.url + '" | pbcopy');
ncp.copy(response.url, function() {
return callback(null, response.url);
});
}

@@ -133,0 +145,0 @@ } else {

@@ -129,2 +129,6 @@ #!/usr/bin/env node

function noop(ignore) {
return ignore;
}
function onInput(err, input) {

@@ -142,3 +146,3 @@ if (err) {

if (argv.diffy) {
cli.postToDiffy(input, argv.diffy);
cli.postToDiffy(input, argv.diffy, noop);
return;

@@ -145,0 +149,0 @@ }

@@ -25,9 +25,11 @@ /*

Utils.prototype.existsSync = function(filePath) {
var result = false;
try {
fs.existsSync(filePath);
result = fs.existsSync(filePath);
} catch (ignore) {
return false;
result = false;
}
return true;
return result || false;
};

@@ -34,0 +36,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc