diff options
author | isaacs <i@izs.me> | 2012-09-13 07:21:08 +0400 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-09-13 07:22:54 +0400 |
commit | 70df4aa74898c14cd1eaf160eeab266418f1578c (patch) | |
tree | 9eaa832f4d48ed6d02cd1d1b36c0119247bb6009 /node_modules | |
parent | 0fc2c2df0ca4ed11d3203eb69c8858749aa6234b (diff) |
Add opener dep
Diffstat (limited to 'node_modules')
-rw-r--r-- | node_modules/opener/LICENSE.txt | 14 | ||||
-rw-r--r-- | node_modules/opener/README.md | 44 | ||||
-rwxr-xr-x | node_modules/opener/opener.js | 55 | ||||
-rw-r--r-- | node_modules/opener/package.json | 34 |
4 files changed, 147 insertions, 0 deletions
diff --git a/node_modules/opener/LICENSE.txt b/node_modules/opener/LICENSE.txt new file mode 100644 index 000000000..087c312b1 --- /dev/null +++ b/node_modules/opener/LICENSE.txt @@ -0,0 +1,14 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2012 Domenic Denicola <domenic@domenicdenicola.com> + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. + diff --git a/node_modules/opener/README.md b/node_modules/opener/README.md new file mode 100644 index 000000000..bf3ff2ac5 --- /dev/null +++ b/node_modules/opener/README.md @@ -0,0 +1,44 @@ +# It Opens Stuff + +That is, in your desktop environment. This will make *actual windows pop up*, with stuff in them: + +```bash +npm install opener -g + +opener http://google.com +opener ./my-file.txt +opener firefox +opener npm run lint +``` + +Also if you want to use it programmatically you can do that too: + +```js +var opener = require("opener"); + +opener("http://google.com"); +opener("./my-file.txt"); +opener("firefox"); +opener("npm run lint"); +``` + +## Use It for Good + +Like opening the user's browser with a test harness in your package's test script: + +```json +{ + "scripts": { + "test": "opener ./test/runner.html" + }, + "devDependencies": { + "opener": "*" + } +} +``` + +## Why + +Because Windows has `start`, Macs have `open`, and *nix has `xdg-open`. At least +[according to some guy on StackOverflow](http://stackoverflow.com/q/1480971/3191). And I like things that work on all +three. Like Node.js. And Opener. diff --git a/node_modules/opener/opener.js b/node_modules/opener/opener.js new file mode 100755 index 000000000..5cdfd7283 --- /dev/null +++ b/node_modules/opener/opener.js @@ -0,0 +1,55 @@ +#!/usr/bin/env node + +"use strict"; + +var childProcess = require("child_process"); + +function opener(args, options, callback) { + // http://stackoverflow.com/q/1480971/3191, but see below for Windows. + var command = process.platform === "win32" ? "cmd" : + process.platform === "darwin" ? "open" : + "xdg-open"; + + if (typeof args === "string") { + args = [args]; + } + + if (typeof options === "function") { + callback = options; + options = {}; + } + + if (options && typeof options === "object" && options.command) { + if (process.platform === "win32") { + // *always* use cmd on windows + args = [options.command].concat(args); + } else { + cmd = options.command; + } + } + + if (process.platform === "win32") { + // On Windows, we really want to use the "start" command. But, the rules regarding arguments with spaces, and + // escaping them with quotes, can get really arcane. So the easiest way to deal with this is to pass off the + // responsibility to "cmd /c", which has that logic built in. + // + // Furthermore, if "cmd /c" double-quoted the first parameter, then "start" will interpret it as a window title, + // so we need to add a dummy empty-string window title: http://stackoverflow.com/a/154090/3191 + args = ["/c", "start", '""'].concat(args); + } + + childProcess.execFile(command, args, options, callback); +} + +// Export `opener` for programmatic access. +// You might use this to e.g. open a website: `opener("http://google.com")` +module.exports = opener; + +// If we're being called from the command line, just execute, using the command-line arguments. +if (require.main && require.main.id === module.id) { + opener(process.argv.slice(2), function (error) { + if (error) { + throw error; + } + }); +} diff --git a/node_modules/opener/package.json b/node_modules/opener/package.json new file mode 100644 index 000000000..436f68ba6 --- /dev/null +++ b/node_modules/opener/package.json @@ -0,0 +1,34 @@ +{ + "name": "opener", + "description": "Opens stuff, like webpages and files and executables, cross-platform", + "version": "1.2.0", + "author": { + "name": "Domenic Denicola", + "email": "domenic@domenicdenicola.com", + "url": "http://domenicdenicola.com" + }, + "license": "WTFPL", + "repository": { + "type": "git", + "url": "git://github.com/domenic/opener.git" + }, + "bugs": { + "url": "http://github.com/domenic/opener/issues" + }, + "main": "opener.js", + "bin": { + "opener": "opener.js" + }, + "scripts": { + "lint": "jshint opener.js --show-non-errors" + }, + "devDependencies": { + "jshint": ">= 0.7.3" + }, + "readme": "# It Opens Stuff\n\nThat is, in your desktop environment. This will make *actual windows pop up*, with stuff in them:\n\n```bash\nnpm install opener -g\n\nopener http://google.com\nopener ./my-file.txt\nopener firefox\nopener npm run lint\n```\n\nAlso if you want to use it programmatically you can do that too:\n\n```js\nvar opener = require(\"opener\");\n\nopener(\"http://google.com\");\nopener(\"./my-file.txt\");\nopener(\"firefox\");\nopener(\"npm run lint\");\n```\n\n## Use It for Good\n\nLike opening the user's browser with a test harness in your package's test script:\n\n```json\n{\n \"scripts\": {\n \"test\": \"opener ./test/runner.html\"\n },\n \"devDependencies\": {\n \"opener\": \"*\"\n }\n}\n```\n\n## Why\n\nBecause Windows has `start`, Macs have `open`, and *nix has `xdg-open`. At least\n[according to some guy on StackOverflow](http://stackoverflow.com/q/1480971/3191). And I like things that work on all\nthree. Like Node.js. And Opener.\n", + "_id": "opener@1.2.0", + "dist": { + "shasum": "cf70d00a43375f86d8789933fa2c99c3190212bd" + }, + "_from": "git://github.com/isaacs/opener" +} |