Created
April 11, 2012 20:28
-
-
Save eager/2362270 to your computer and use it in GitHub Desktop.
Node examples for ThisService <http://wafflesoftware.net/thisservice/>
This file contains hidden or 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
#!/usr/local/bin/node | |
// ThisService node.js service script example, by Christian Eager | |
// Service type: Acts on input | |
// | |
// Node.js does *not* ship with OS X | |
// Download and installation instructions are available at http://nodejs.org | |
process.stdin.resume() | |
// Makes the data event emit a string instead of a Buffer | |
process.stdin.setEncoding('utf8') | |
var input = "" | |
process.stdin.on('data', function (chunk) { | |
input += chunk | |
}) | |
process.stdin.on('end', function () { | |
// input now contains the contents of STDIN | |
// Write your script here | |
}) |
This file contains hidden or 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
#!/usr/local/bin/node | |
// ThisService node.js service script example, by Christian Eager | |
// Service type: Filter | |
// | |
// Node.js does *not* ship with OS X | |
// Download and installation instructions are available at http://nodejs.org | |
process.stdin.resume() | |
// Makes the data event emit a string instead of a Buffer | |
process.stdin.setEncoding('utf8') | |
var input = "" | |
process.stdin.on('data', function (chunk) { | |
input += chunk | |
}) | |
process.stdin.on('end', function () { | |
// input now contains the contents of STDIN | |
// Write your script here | |
// Be sure to print anything you want the service to output | |
}) |
This file contains hidden or 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
#!/usr/local/bin/node | |
// ThisService node.js service script example, by Christian Eager | |
// Service type: Produces output | |
// | |
// Node.js does *not* ship with OS X | |
// Download and installation instructions are available at http://nodejs.org | |
// Write your script here | |
// Be sure to print anything you want the service to output | |
// e.g. process.stdout.write("Hello, world") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@matthewkremer I’m not quite sure what you mean by global. Were they installed using
npm install -g
?I think the root of the need to hard-code the path to
node
, rather than usingenv
, is thatNSTask
, which ThisService uses to spawn the scripts, doesn’t take the user’s environment (e.g.,~/.bashrc
) into account. Looking into this issue further has been on my list of interesting things to solve for…the past two years.