Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Hello from Node.js

View hello.js
1
process.stdout.write("Hello from nodejs.");
View hello.js
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]
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.