Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
Hello from Node.js
process.stdout.write("Hello from nodejs.");
import sublime
import sublime_plugin
import os
import subprocess
PLUGIN_FOLDER = os.path.dirname(os.path.realpath(__file__))
class HelloNodeCommand(sublime_plugin.TextCommand):
def run(self, edit):
node = "node"
scriptPath = PLUGIN_FOLDER + "/hello.js"
output = run_process([node, scriptPath]).decode("utf-8");
region = self.view.sel()[0]
pos = region.begin()
self.view.insert(edit, pos, output)
def run_process(args):
cmd = '"' + '" "'.join(args) + '"'
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
return subprocess.Popen(cmd, stdout=subprocess.PIPE, startupinfo=startupinfo).communicate()[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.