Created
April 5, 2014 19:46
-
-
Save julianlconnor/9997143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
q.all([only(), debug()]) | |
.then(flatten) | |
.then(function(lines) { | |
var dfd = q.defer(); | |
var rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
rl.question(lines[0] + ' -- is this cool? (n)o , (y)es >', function(answer) { | |
if ( answer.toLower() === 'n' ) { | |
/** | |
* This should stop the promise chain and trigger the `fail`. | |
*/ | |
dfd.reject('line has been rejected'); | |
} else { | |
/** | |
* This should continue the promise chain; | |
*/ | |
dfd.resolve('line has been accepted'); | |
} | |
rl.close(); | |
}); | |
return dfd.promise; | |
}) | |
.fail(function(err) { | |
console.log(err, '--- might not want these in yr commit ---\n'); | |
exit(1); | |
}) | |
.finally(function() { | |
console.log('status of dfd', dfd.promise.isFulfilled()); | |
exit(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment