mocha-jshint
Advanced tools
Comparing version 2.0.2 to 2.1.0
42
git.js
@@ -9,13 +9,17 @@ var exec = require('child_process').exec; | ||
} | ||
var maxCount = options.commits || 1; | ||
return exec(format('git log --pretty=format:%h --max-count=%d', maxCount), findSHA); | ||
if (options.masterDiff) { | ||
return exec('git rev-parse --abbrev-ref HEAD', getFilesChangesInCurrentBranch); | ||
} | ||
return compareLatestCommits(); | ||
function findSHA(err, stdout) { | ||
function getFilesChangesInCurrentBranch(err, stdout) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
var shas = stdout.split('\n'); | ||
var shaIndex = Math.min(options.commits || 0, shas.length - 1); | ||
var command = format('git diff --name-only %s %s', shas[0], shas[shaIndex]); | ||
if(options.modified){ | ||
var branch = stdout.trim(); | ||
if (branch === 'master') { | ||
return compareLatestCommits(); | ||
} | ||
var command = format('git diff --name-only "master...%s"', branch); | ||
if (options.modified) { | ||
command += ' && git diff --name-only HEAD'; | ||
@@ -26,2 +30,25 @@ } | ||
function compareLatestCommits() { | ||
var maxCount = (options.commits || 0) + 1; | ||
return exec(format('git log --pretty=format:%h --max-count=%d', maxCount), findSHA); | ||
} | ||
function findSHA(err, stdout) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
var shas = stdout.split('\n').filter(Boolean); | ||
var command = ''; | ||
if (shas.length) { | ||
command += format('git diff --name-only %s %s', shas[0], shas[shas.length - 1]); | ||
} | ||
if (options.modified) { | ||
command += ((!!command) ? ' && ' : '') + 'git diff --name-only HEAD'; | ||
} | ||
if (!command) { | ||
return cb(null, []); | ||
} | ||
return exec(command, returnFiles); | ||
} | ||
function returnFiles(err, stdout) { | ||
@@ -38,2 +65,1 @@ if (err) { | ||
}; | ||
@@ -0,0 +0,0 @@ var path = require('path'); |
{ | ||
"name": "mocha-jshint", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "run JSHint as mocha tests", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -38,6 +38,22 @@ mocha-jshint [![npm version](https://badge.fury.io/js/mocha-jshint.svg)](http://badge.fury.io/js/mocha-jshint) [![Build Status](https://travis-ci.org/ebdrup/mocha-jshint.svg?branch=master)](https://travis-ci.org/ebdrup/mocha-jshint) [![Dependency Status](https://david-dm.org/ebdrup/mocha-jshint.svg)](https://david-dm.org/ebdrup/mocha-jshint) [![devDependency Status](https://david-dm.org/ebdrup/mocha-jshint/dev-status.svg)](https://david-dm.org/ebdrup/mocha-jshint#info=devDependencies) | ||
``` | ||
This means that jshint will only hint the files that are modified according to git, and the files modified in the last | ||
This means that jshint will only lint the files that are modified on disk according to git, and the files modified in the last | ||
two git commits. | ||
There is also the `masterDiff` option: | ||
```js | ||
require('mocha-jshint')({ | ||
git: { | ||
modified: true, | ||
commits: 2, | ||
masterDiff:true | ||
} | ||
}); | ||
``` | ||
This means that if we are on any other branch than `master`, only the files changed compared to the `master` branch | ||
will be linted. | ||
If we are on the `master` branch, only the files that are modified on disk according to git, and the files modified in the last | ||
two git commits will be linted. | ||
configuring jshint | ||
@@ -44,0 +60,0 @@ ------------------ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6921
109
86
1