Created
August 18, 2013 17:44
-
-
Save unlight/6262932 to your computer and use it in GitHub Desktop.
Hello from Node.js
This file contains 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
process.stdout.write("Hello from nodejs."); |
This file contains 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
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