-
-
Save bingeboy/9265187 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var fs = require('fs'); | |
var child_process = require('child_process'); | |
var spawn = child_process.spawn; | |
function openEditor(file) { | |
var cp = spawn(process.env.EDITOR, [file], { | |
customFds: [ | |
process.stdin, | |
process.stdout, | |
process.stderr | |
] | |
}); | |
cp.on('exit', function() { | |
console.log('editor ended'); | |
var content = fs.readFileSync(file, 'utf8'); | |
console.log(content); | |
}); | |
} | |
child_process.exec('mktemp', function(err, stdout, stderr) { | |
if(err) { | |
console.log(err); | |
return; | |
} | |
// remove the \n | |
openEditor(stdout.substr(0, stdout.length-1)); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment