Skip to content

Commit

Permalink
Merge pull request #3 from JonnyBurger/master
Browse files Browse the repository at this point in the history
Allow input from stdin
  • Loading branch information
albinekb authored Mar 30, 2017
2 parents 0dbb833 + 9f5992b commit ac8c783
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/usr/bin/env node
const open = require('open-pip')
const ora = require('ora')
const getStdin = require('get-stdin')
const spinner = ora().start()

const input = process.argv[2]
getStdin()
.then(stdin => {
if (stdin) return stdin.trim()

if (!input) throw new Error('No url supplied')

open(input).then(() => {
const input = process.argv[2]
if (!input) throw new Error('No url supplied')
return input
})
.then(input => open(input))
.then(() => {
spinner.stopAndPersist({ symbol: '🌟', text: 'Running!' })
})
.catch((err) => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"open-pip": "index.js"
},
"dependencies": {
"get-stdin": "^5.0.1",
"open-pip": "^3.0.5",
"ora": "^1.2.0"
}
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ fs-promise@^2.0.2:
mz "^2.6.0"
thenify-all "^1.6.0"

get-stdin@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-5.0.1.tgz#122e161591e21ff4c52530305693f20e6393a398"

graceful-fs@^4.1.2, graceful-fs@^4.1.6:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
Expand Down

0 comments on commit ac8c783

Please sign in to comment.