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

parse-diff

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-diff - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

28

__tests__/parse.spec.js

@@ -39,2 +39,30 @@ const parse = require("../index");

it("should parse simple git-like diff with file enclosed by double-quote", function() {
const diff = `\
diff --git "a/file1" "b/file2"
similarity index 100%
rename from "file1"
rename to "file2"\
`;
const files = parse(diff);
expect(files.length).toBe(1);
const file = files[0];
expect(file.from).toBe("file1");
expect(file.to).toBe("file2");
expect(file.chunks.length).toBe(0);
});
it('should parse file names for changed binaries with spaces in their names', function() {
const diff = `\
diff --git a/Artsy_Tests/ReferenceImages/ARTopMenuViewControllerSpec/selects 'home' by default as ipad@2x.png b/Artsy_Tests/ReferenceImages/ARTopMenuViewControllerSpec/selects 'home' by default as ipad@2x.png
index fc72ba34b..ec373e9a4 100644
Binary files a/Artsy_Tests/ReferenceImages/ARTopMenuViewControllerSpec/selects 'home' by default as ipad@2x.png and b/Artsy_Tests/ReferenceImages/ARTopMenuViewControllerSpec/selects 'home' by default as ipad@2x.png differ\
`;
const files = parse(diff);
expect(files.length).toBe(1)
const file = files[0]
expect(file.from).toBe("Artsy_Tests/ReferenceImages/ARTopMenuViewControllerSpec/selects 'home' by default as ipad@2x.png")
expect(file.to).toBe("Artsy_Tests/ReferenceImages/ARTopMenuViewControllerSpec/selects 'home' by default as ipad@2x.png")
});
it("should parse diff with new file mode line", function() {

@@ -41,0 +69,0 @@ const diff = `\

6

index.js

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 2.4.1
// Generated by CoffeeScript 2.5.1
// parses unified diff

@@ -157,5 +157,5 @@ // http://www.gnu.org/software/diffutils/manual/diffutils.html#Unified-Format

}
fileNames = s.match(/a\/.*(?= b)|b\/.*$/g);
fileNames = s.match(/a\/.*(?=["']? ["']?b\/)|b\/.*$/g);
fileNames.map(function(fileName, i) {
return fileNames[i] = fileName.replace(/^(a|b)\//, '');
return fileNames[i] = fileName.replace(/^(a|b)\//, '').replace(/("|')$/, '');
});

@@ -162,0 +162,0 @@ return fileNames;

{
"name": "parse-diff",
"version": "0.6.0",
"version": "0.7.0",
"description": "Unified diff parser",

@@ -20,4 +20,4 @@ "author": "Sergey Todyshev <stodyshev@gmail.com>",

"coffeelint": "^2.1.0",
"coffeescript": "^2.4.1",
"jest": "^24.9.0"
"coffeescript": "^2.5.1",
"jest": "^25.1.0"
},

@@ -24,0 +24,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

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