Skip to content

Commit

Permalink
fix(prompt): the prompt would select unstaged changes by default - no…
Browse files Browse the repository at this point in the history
…w it ignores unstaged ones
  • Loading branch information
jpnelson committed Jun 6, 2016
1 parent 0f8c411 commit a7d67bd
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,26 @@ function getAllPackages () {
return PackageUtilities.getPackages(packagesLocation);
}

function getChangedComponents () {
const changedComponents = [];
function isStatusStaged (statusLine) {
const modifiedAddedDeletedRenamedCopied = 'MADRC'; // see git status --help (short output format)
const status = statusLine.split(' ');
const stagedStatus = status[0];
return modifiedAddedDeletedRenamedCopied.indexOf(stagedStatus) !== -1;
}

var status = shell.exec('git status . --porcelain', {silent: true}).stdout;
function isFileStaged (status, file) {
const stagedChanges = status.split('\n').filter(isStatusStaged);
return stagedChanges.some(function (stagedChange) {
return stagedChange.indexOf(file) !== -1;
});
}

function getChangedComponents () {
let changedComponents = [];
const status = shell.exec('git status . --short', {silent: true}).stdout;

getAllPackages().forEach(function (pkg) {
if (status.indexOf(path.relative('.', pkg.location)) !== -1) {
if (isFileStaged(status, path.relative('.', pkg.location))) {
changedComponents.push(pkg.name);
}
});
Expand Down

0 comments on commit a7d67bd

Please sign in to comment.