staged-git-files
Advanced tools
+17
-11
@@ -15,3 +15,3 @@ var spawn = require("child_process").spawn; | ||
| } else { | ||
| var command = "git diff-index --cached --name-status --diff-filter=" + filter + " " + head; | ||
| var command = "git diff-index --cached --name-status -M --diff-filter=" + filter + " " + head; | ||
| run(command, function(err, stdout, stderr) { | ||
@@ -95,10 +95,16 @@ if (err || stderr) { | ||
| /* =============================================================================================================================== | ||
| ** PER git diff-index --help | ||
| ** --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]] | ||
| ** Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular | ||
| ** file, symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B). Any | ||
| ** combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all | ||
| ** paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches | ||
| ** other criteria, nothing is selected. | ||
| ** ============================================================================================================================ */ | ||
| ** PER docs at https://git-scm.com/docs/git-diff-index | ||
| ** Possible status letters are: | ||
| ** A: addition of a file | ||
| ** C: copy of a file into a new one | ||
| ** D: deletion of a file | ||
| ** M: modification of the contents or mode of a file | ||
| ** R: renaming of a file | ||
| ** T: change in the type of the file | ||
| ** U: file is unmerged (you must complete the merge before it can be committed) | ||
| ** X: "unknown" change type (most probably a bug, please report it) | ||
| ** | ||
| ** Status letters C and R are always followed by a score (denoting the percentage of similarity between the source and target of the move or copy). | ||
| ** Status letter M may be followed by a score (denoting the percentage of dissimilarity) for file rewrites. | ||
| ** ============================================================================================================================ */ | ||
@@ -117,3 +123,3 @@ var map = { | ||
| return map[code]; | ||
| return map[code.charAt(0)]; | ||
| } | ||
@@ -131,3 +137,3 @@ | ||
| var result = { | ||
| filename: parts[1], | ||
| filename: parts[2] || parts[1], | ||
| status: codeToStatus(parts[0]) | ||
@@ -134,0 +140,0 @@ } |
+1
-1
| { | ||
| "name": "staged-git-files", | ||
| "version": "0.0.4", | ||
| "version": "1.0.0", | ||
| "devDependencies": { | ||
@@ -5,0 +5,0 @@ "should": "~2.0.1", |
+22
-0
@@ -109,2 +109,24 @@ describe("As a module", function() { | ||
| it("I should find renames", function(done) { | ||
| addAndCommitFile(function(err, data) { | ||
| if (err) { | ||
| done(err); | ||
| } else { | ||
| var newFileName = randomFileName([8, 3]); | ||
| moveFile({ | ||
| oldFileName: data.filename, | ||
| newFileName: newFileName | ||
| }, function(err) { | ||
| var sgf = newSGF(); | ||
| sgf(asyncCatch(done, function(results) { | ||
| results.length.should.equal(1); | ||
| results[0].filename.should.equal(newFileName); | ||
| results[0].status.should.equal("Renamed"); | ||
| })); | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
| it("if includeContent is set to true I should return the file paths, their git status and the content", function(done) { | ||
@@ -111,0 +133,0 @@ addFile(function(err, data) { |
+20
-1
@@ -63,3 +63,3 @@ require("should"); | ||
| var randomFileName = function(lengths) { | ||
| randomFileName = function(lengths) { | ||
| var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | ||
@@ -88,2 +88,21 @@ var filename = randomString(possible, lengths[0]); | ||
| moveFile = function(opts, callback) { | ||
| var oldPath = test_folder + "/" + opts.oldFileName; | ||
| var newPath = test_folder + "/" + opts.newFileName; | ||
| fs.rename(oldPath, newPath, function(err) { | ||
| if (err) { | ||
| callback(err); | ||
| } else { | ||
| run("git add " + opts.oldFileName + " " + opts.newFileName, function(err, stdout, stderr) { | ||
| if (err || stderr) { | ||
| callback(err || new Error(stderr)); | ||
| } else { | ||
| callback(null, opts); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
| } | ||
| newFile = function(opts, callback) { | ||
@@ -90,0 +109,0 @@ |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
17149
9.84%435
10.97%1
-50%