Last active
July 20, 2017 02:17
-
-
Save ekoneko/1a165cff352609df017e48ebfa7e0f5f to your computer and use it in GitHub Desktop.
node trick
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
const child_process = require('child_process'); | |
const editor = process.env.EDITOR || 'vi'; | |
const child = child_process.spawn(editor, ['/tmp/somefile.txt'], { | |
stdio: 'inherit' | |
}); | |
child.on('exit', function (e, code) { | |
console.log("finished"); | |
}); |
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
const path = require('path'); | |
const root = require.main.filename; | |
const rootPath = path.dirname(root); | |
console.log(rootPath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment