-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7bfdad1
Showing
7 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules/ | ||
/npm-debug.log |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"camelcase": "true", | ||
"curly": true, | ||
"eqeqeq": true, | ||
"es5": true, | ||
"globalstrict": true, | ||
"immed": true, | ||
"indent": 4, | ||
"latedef": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"node": true, | ||
"nonew": true, | ||
"nomen": true, | ||
"quotmark": "double", | ||
"trailing": true, | ||
"undef": true, | ||
"unused": true, | ||
"white": true | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/node_modules/ | ||
/npm-debug.log | ||
|
||
/.jshintrc | ||
/.npmignore |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2012 Domenic Denicola <[email protected]> | ||
|
||
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. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env node | ||
|
||
"use strict"; | ||
|
||
var childProcess = require("child_process"); | ||
|
||
function opener(args, options, callback) { | ||
// http://stackoverflow.com/q/1480971/3191 | ||
var command = process.platform === "win32" ? "start" : | ||
process.platform === "darwin" ? "open" : | ||
"xdg-open"; | ||
|
||
if (typeof args === "string") { | ||
args = [args]; | ||
} | ||
|
||
childProcess.exec(command + " " + args.join(" "), 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; | ||
} | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "opener", | ||
"description": "Opens stuff, like webpages and files and executables, cross-platform", | ||
"version": "1.0.0", | ||
"author": "Domenic Denicola <[email protected]> (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.js", | ||
"scripts": { | ||
"lint": "jshint opener.js --show-non-errors" | ||
}, | ||
"devDependencies": { | ||
"jshint": ">= 0.7.3" | ||
} | ||
} |