Skip to content

Instantly share code, notes, and snippets.

@ekoneko
Last active July 20, 2017 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekoneko/1a165cff352609df017e48ebfa7e0f5f to your computer and use it in GitHub Desktop.
Save ekoneko/1a165cff352609df017e48ebfa7e0f5f to your computer and use it in GitHub Desktop.
node trick
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");
});
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