Skip to content

Commit

Permalink
check file is in contribs directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Jessica Lord committed Sep 17, 2014
1 parent 548a42a commit f3bef7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions problems/branches_arent_just_for_birds/solution.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
console.log("Found branch as expected!")
console.log("Changes have been pushed!")
console.log("File in contributors folder!")
17 changes: 15 additions & 2 deletions problems/branches_arent_just_for_birds/verify.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
#!/usr/bin/env node

var exec = require('child_process').exec
var fs = require('fs')
var path = require('path')
var username = ""

// get their username
// verify branch matches username, case too.
// verify they've pushed
// check the file is in contributors directory

exec('git config user.username', function(err, stdout, stdrr) {
var username = stdout.trim()
username = stdout.trim()

exec('git rev-parse --abbrev-ref HEAD', function(err, stdout, stderr) {
var actualBranch = stdout.trim()
var expectedBranch = "add-" + username
if (actualBranch.match(expectedBranch)) {
return console.log("Found branch as expected!")
console.log("Found branch as expected!")
checkPush(actualBranch)
} else {
console.log("Branch name expected: " + expectedBranch)
Expand All @@ -26,5 +30,14 @@ function checkPush(branchname) {
exec('git reflog show origin/' + branchname, function(err, stdout, stderr) {
if (stdout.match("update by push")) console.log("Changes have been pushed!")
else console.log("Changes not pushed")
findFile()
})
}

function findFile() {
fs.readdir(path.join(process.cwd(), "/contributors/"), function(err, files) {
var allFiles = files.join()
if (allFiles.match(username)) console.log("File in contributors folder!")
else console.log("File NOT in contribs.. folder!")
})
}

0 comments on commit f3bef7c

Please sign in to comment.