Skip to content

Commit

Permalink
Version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
domenic committed Aug 6, 2012
0 parents commit 7bfdad1
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules/
/npm-debug.log
20 changes: 20 additions & 0 deletions .jshintrc
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
}
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/node_modules/
/npm-debug.log

/.jshintrc
/.npmignore
14 changes: 14 additions & 0 deletions LICENSE.txt
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.

44 changes: 44 additions & 0 deletions README.md
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.
31 changes: 31 additions & 0 deletions opener.js
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;
}
});
}
22 changes: 22 additions & 0 deletions package.json
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"
}
}

0 comments on commit 7bfdad1

Please sign in to comment.