You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

staged-git-files

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

staged-git-files - npm Package Compare versions

Comparing version
1.0.0
to
1.1.0
+22
.circleci/config.yml
version: 2
jobs:
build:
docker:
- image: circleci/node:7.10
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- v1-dependencies-
- run: git config --global user.email "1551510+mcwhittemore@users.noreply.github.com"
- run: git config --global user.name "test staged-git-files"
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: npm test
#!/usr/bin/env node
var sgf = require('../');
sgf(function(err, files) {
if (err) {
console.error(err.message);
process.exit(1);
}
files.forEach(function(f) {
console.log(f.status+' '+f.filename);
});
});
# Change Log
## 1.1.0
- Provide a binary called `sgf` [#11](https://github.com/mcwhittemore/staged-git-files/pull/11)
- Improve git request to not include slow flags when the results of those flags aren't needed [#8](https://github.com/mcwhittemore/staged-git-files/pull/8) by [twhitbeck](https://github.com/twhitbeck).
## 1.0.0
- Include renamed files [#7](https://github.com/mcwhittemore/staged-git-files/pull/7) by [twhitbeck](https://github.com/twhitbeck).
## 0.0.4
- Improve tests to cover many more files [#3](https://github.com/mcwhittemore/staged-git-files/pull/3).
## 0.0.3
- handle spaces in files [#1](https://github.com/mcwhittemore/staged-git-files/pull/1) by [romeovs](https://github.com/romeovs)
## 0.0.2
- sgf.includeContent added. Now it is possible to also get the file content
## 0.0.1
- The mvp
+12
-7

@@ -15,3 +15,10 @@ var spawn = require("child_process").spawn;

} else {
var command = "git diff-index --cached --name-status -M --diff-filter=" + filter + " " + head;
var command = "git diff-index --cached --name-status";
if (filter.indexOf('R') !== -1) {
command += " -M";
}
command += " --diff-filter=" + filter + " " + head;
run(command, function(err, stdout, stderr) {

@@ -61,5 +68,2 @@ if (err || stderr) {

// var exec = require("child_process").exec;
// exec("cd '" + module.exports.cwd + "' && " + command, callback);
var bits = command.split(" ");

@@ -95,3 +99,3 @@ var args = bits.slice(1);

var codeToStatus = function(code) {
/* ===============================================================================================================================
/* =======================================================================================================
** PER docs at https://git-scm.com/docs/git-diff-index

@@ -108,5 +112,6 @@ ** Possible status letters are:

**
** 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 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.
** ============================================================================================================================ */
** ======================================================================================================= */

@@ -113,0 +118,0 @@ var map = {

{
"name": "staged-git-files",
"version": "1.0.0",
"version": "1.1.0",
"devDependencies": {

@@ -16,2 +16,5 @@ "should": "~2.0.1",

},
"bin": {
"sgf": "bin/cli.js"
},
"repository": {

@@ -18,0 +21,0 @@ "type": "git",

+11
-15

@@ -7,9 +7,6 @@ # Staged Git Files

**Download**
`npm install staged-git-files`
**In Code**
```
```js
var sgf = require("staged-git-files");

@@ -23,3 +20,3 @@ sgf(function(err, results){

```
```json
[

@@ -41,2 +38,11 @@ {

## Usage as a cli
```sh
$ staged-git-files
Added package.json
Modified readme.md
Renamed index.js
```
## API

@@ -95,11 +101,1 @@

* Unknown (X)
## Change Log
### 0.0.2
* sgf.includeContent added. Now it is possible to also get the file content
### 0.0.1
* The mvp

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

describe("As a module", function() {

@@ -75,2 +76,40 @@

it("I, being the cli, should log the file paths and their git status", function(done) {
addFiles(2, function(err, data) {
if (err) return done(err);
var sorter = function(a,b){
if(a.filename > b.filename){
return 1;
}
else if(a.filename < b.filename){
return -1;
}
else{
return 0;
}
};
data.sort(sorter);
exec('../../bin/cli.js', {cwd: test_folder}, function(err, stdout, stderr) {
if (err) return done(err);
var results = stdout.trim().split('\n').map(function(line) {
var p = line.split(' ');
var status = p[0];
var filename = p.slice(1).join(' ');
return {
status: status,
filename: filename
};
});
results.sort(sorter);
for(var i=0; i<results.length; i++){
results[i].filename.should.equal(data[i].filename);
results[i].status.should.equal("Added");
}
done();
});
});
});
it("I should return the file paths and their git status", function(done) {

@@ -132,2 +171,24 @@ this.timeout(1000000000);

it("if 'R' flag is not included I should not 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('A', asyncCatch(done, function(results) {
results.length.should.equal(1);
results[0].filename.should.equal(newFileName);
results[0].status.should.equal("Added");
}));
});
}
});
});
it("if includeContent is set to true I should return the file paths, their git status and the content", function(done) {

@@ -161,2 +222,2 @@ addFile(function(err, data) {

});
});
});

@@ -50,2 +50,4 @@ require("should");

newSGF = function() {
delete require.cache[require.resolve('../')];
var sgf = require("../");

@@ -52,0 +54,0 @@ sgf.cwd = test_folder

{
"pre-commit": {
"beautify.hks": "0.0.1",
"esprima.hks": "0.0.0"
}
}