Permalink
Browse files

NodeJS support

  • Loading branch information...
1 parent a9d66fa commit 588eeb1ca6b1459c56f5849ff0241e3d4adc1390 Philip Mateescu committed Sep 7, 2011
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>NSServices</key>
+ <array>
+ <dict>
+ <key>NSMenuItem</key>
+ <dict>
+ <key>default</key>
+ <string>Execute as NodeJS code</string>
+ </dict>
+ <key>NSMessage</key>
+ <string>runWorkflowAsService</string>
+ <key>NSReturnTypes</key>
+ <array>
+ <string>public.utf8-plain-text</string>
+ </array>
+ <key>NSSendTypes</key>
+ <array>
+ <string>public.utf8-plain-text</string>
+ </array>
+ </dict>
+ </array>
+</dict>
+</plist>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>AMApplicationBuild</key>
+ <string>329</string>
+ <key>AMApplicationVersion</key>
+ <string>2.2</string>
+ <key>AMDocumentVersion</key>
+ <string>2</string>
+ <key>actions</key>
+ <array>
+ <dict>
+ <key>action</key>
+ <dict>
+ <key>AMAccepts</key>
+ <dict>
+ <key>Container</key>
+ <string>List</string>
+ <key>Optional</key>
+ <true/>
+ <key>Types</key>
+ <array>
+ <string>com.apple.cocoa.string</string>
+ </array>
+ </dict>
+ <key>AMActionVersion</key>
+ <string>2.0.2</string>
+ <key>AMApplication</key>
+ <array>
+ <string>Automator</string>
+ </array>
+ <key>AMParameterProperties</key>
+ <dict>
+ <key>COMMAND_STRING</key>
+ <dict/>
+ <key>CheckedForUserDefaultShell</key>
+ <dict/>
+ <key>inputMethod</key>
+ <dict/>
+ <key>shell</key>
+ <dict/>
+ <key>source</key>
+ <dict/>
+ </dict>
+ <key>AMProvides</key>
+ <dict>
+ <key>Container</key>
+ <string>List</string>
+ <key>Types</key>
+ <array>
+ <string>com.apple.cocoa.string</string>
+ </array>
+ </dict>
+ <key>ActionBundlePath</key>
+ <string>/System/Library/Automator/Run Shell Script.action</string>
+ <key>ActionName</key>
+ <string>Run Shell Script</string>
+ <key>ActionParameters</key>
+ <dict>
+ <key>COMMAND_STRING</key>
+ <string>NODE_LOC=node
+js=$(cat &lt;&lt;JS
+try {
+$*
+} catch(err) {
+ console.log("Error: %s", err);
+}
+JS
+)
+# echo "$js" &gt; test.js
+
+echo "$js" | $NODE_LOC 2&gt;&amp;1
+
+exit 0</string>
+ <key>CheckedForUserDefaultShell</key>
+ <true/>
+ <key>inputMethod</key>
+ <integer>1</integer>
+ <key>shell</key>
+ <string>/bin/bash</string>
+ <key>source</key>
+ <string></string>
+ </dict>
+ <key>BundleIdentifier</key>
+ <string>com.apple.RunShellScript</string>
+ <key>CFBundleVersion</key>
+ <string>2.0.2</string>
+ <key>CanShowSelectedItemsWhenRun</key>
+ <false/>
+ <key>CanShowWhenRun</key>
+ <true/>
+ <key>Category</key>
+ <array>
+ <string>AMCategoryUtilities</string>
+ </array>
+ <key>Class Name</key>
+ <string>RunShellScriptAction</string>
+ <key>InputUUID</key>
+ <string>3E25AF15-AB0C-4033-9AA6-852FACCCA9C7</string>
+ <key>Keywords</key>
+ <array>
+ <string>Shell</string>
+ <string>Script</string>
+ <string>Command</string>
+ <string>Run</string>
+ <string>Unix</string>
+ </array>
+ <key>OutputUUID</key>
+ <string>1A6036EF-1E0D-4032-84E4-97C47C5D2240</string>
+ <key>UUID</key>
+ <string>F79F8C71-BBFB-400D-8C37-7DA770DFD832</string>
+ <key>UnlocalizedApplications</key>
+ <array>
+ <string>Automator</string>
+ </array>
+ <key>arguments</key>
+ <dict>
+ <key>0</key>
+ <dict>
+ <key>default value</key>
+ <integer>0</integer>
+ <key>name</key>
+ <string>inputMethod</string>
+ <key>required</key>
+ <string>0</string>
+ <key>type</key>
+ <string>0</string>
+ <key>uuid</key>
+ <string>0</string>
+ </dict>
+ <key>1</key>
+ <dict>
+ <key>default value</key>
+ <string></string>
+ <key>name</key>
+ <string>source</string>
+ <key>required</key>
+ <string>0</string>
+ <key>type</key>
+ <string>0</string>
+ <key>uuid</key>
+ <string>1</string>
+ </dict>
+ <key>2</key>
+ <dict>
+ <key>default value</key>
+ <false/>
+ <key>name</key>
+ <string>CheckedForUserDefaultShell</string>
+ <key>required</key>
+ <string>0</string>
+ <key>type</key>
+ <string>0</string>
+ <key>uuid</key>
+ <string>2</string>
+ </dict>
+ <key>3</key>
+ <dict>
+ <key>default value</key>
+ <string></string>
+ <key>name</key>
+ <string>COMMAND_STRING</string>
+ <key>required</key>
+ <string>0</string>
+ <key>type</key>
+ <string>0</string>
+ <key>uuid</key>
+ <string>3</string>
+ </dict>
+ <key>4</key>
+ <dict>
+ <key>default value</key>
+ <string>/bin/sh</string>
+ <key>name</key>
+ <string>shell</string>
+ <key>required</key>
+ <string>0</string>
+ <key>type</key>
+ <string>0</string>
+ <key>uuid</key>
+ <string>4</string>
+ </dict>
+ </dict>
+ <key>conversionLabel</key>
+ <integer>0</integer>
+ <key>isViewVisible</key>
+ <true/>
+ <key>location</key>
+ <string>286.000000:425.000000</string>
+ <key>nibPath</key>
+ <string>/System/Library/Automator/Run Shell Script.action/Contents/Resources/English.lproj/main.nib</string>
+ </dict>
+ <key>isViewVisible</key>
+ <true/>
+ </dict>
+ </array>
+ <key>connectors</key>
+ <dict/>
+ <key>workflowMetaData</key>
+ <dict>
+ <key>serviceInputTypeIdentifier</key>
+ <string>com.apple.Automator.text</string>
+ <key>serviceOutputTypeIdentifier</key>
+ <string>com.apple.Automator.text</string>
+ <key>serviceProcessesInput</key>
+ <integer>0</integer>
+ <key>workflowTypeIdentifier</key>
+ <string>com.apple.Automator.servicesMenu</string>
+ </dict>
+</dict>
+</plist>
View
@@ -4,7 +4,7 @@ if [ -n "$1" ] ; then
install_what=$1
else
echo "Choose the version of Yoke to install:"
- read -p "PHP, Python, Ruby, Bash, All [hyRba]? " install_choice
+ read -p "PHP, Python, Ruby, Bash, Node.js, All [hyRbna]? " install_choice
install_what=${install_choice:-R}
fi
echo "-$1-"
@@ -43,6 +43,25 @@ case $install_what in
cp -r -v Services/ExecuteRubyInlineV3.workflow ~/Library/Services/
echo "Done. Shortcut is Command + > or Command + Shift + ."
;;
+ [nN] | --node )
+ echo "Installing node.js service:"
+ # test for node version number - we need 0.5 or later
+ NODE_LOC=$(which node)
+ if [ -z "$NODE_LOC" ] ; then
+ echo "FAILED: Couldn't find node in your path."
+ else
+ verok=$(node -v | awk -Fv '{print $NF}' | awk -F. '{ if ($1 >= 0 && $2 >= 5) print "OK" }')
+ if [ "$verok" == "OK" ] ; then
+ cp -r -v Services/"Execute as NodeJS code.workflow" ~/Library/Services/
+ echo "s#NODE_LOC=node#NODE_LOC=$NODE_LOC#"
+ sed -i -e "s#NODE_LOC=node#NODE_LOC=$NODE_LOC#" ~/Library/Services/"Execute as NodeJS code.workflow"/Contents/document.wflow
+ echo "Done. You will need to assign a shortcut in:"
+ echo "System Preferences... -> Keyboard -> Keyboard Shortcuts -> Services -> Text"
+ else
+ echo "FAILED: need at least v0.5. You have `node -v`."
+ fi
+ fi
+ ;;
[aA] | -a | --all )
echo "Installing all services:"
#echo "cp -r -v Services/* ~/Library/Services/"
@@ -0,0 +1,15 @@
+js=$(cat <<JS
+try {
+$*
+} catch(err) {
+ console.log("Error: %s", err);
+}
+JS
+)
+echo "$js" > test.js
+
+echo "$js" | node
+
+
+
+

0 comments on commit 588eeb1

Please sign in to comment.