public
Created

Hello from Node.js

  • Download Gist
hello.js
JavaScript
1
process.stdout.write("Hello from nodejs.");
hello_node.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
import sublime
import sublime_plugin
import os
import subprocess
 
PLUGIN_FOLDER = os.path.dirname(os.path.realpath(__file__))
 
#view.run_command("hello_node")
 
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]

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.