Skip to content

Commit 5c6ac7d

Browse files
committed
nodejs cli
1 parent e50c67e commit 5c6ac7d

5 files changed

Lines changed: 43 additions & 0 deletions

File tree

nodejs-cli/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Creating a Node.js CLI
2+
3+
> [https://www.youtube.com/watch?v=C9xGEJ80jjs](https://www.youtube.com/watch?v=C9xGEJ80jjs)
4+
5+
Install [io.js](https://iojs.org/en/index.html).
6+
7+
Run `./cli.js` to run the example.

nodejs-cli/bear.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ˁ˚ᴥ˚ˀ

nodejs-cli/bears.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ʕ•ᴥ•ʔ
2+
ˁ˚ᴥ˚ˀ
3+
ʕ·͡ᴥ·ʔ
4+
óÔÔò
5+
(● ̄(エ) ̄ ●)
6+
⊂(・(ェ)・)⊃
7+
ʕ•͡ ᴥ•͡ ʔ
8+
ʕ•͡ᴥ•ʔ
9+
(●`・(エ)・ ´●)
10+
ʕノ•ᴥ•ʔノ ︵ ┻━┻

nodejs-cli/cli.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env node
2+
3+
var fs = require('fs');
4+
var path = require('path');
5+
6+
fs.readFile(path.resolve(__dirname, 'bears.txt'), function (err, data) {
7+
var bears = data.toString().split('\n');
8+
var bear = bears[Math.floor(Math.random() * bears.length)];
9+
console.log(bear);
10+
});

nodejs-cli/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "bearme",
3+
"version": "1.1.0",
4+
"description": "",
5+
"main": "cli.js",
6+
"bin": {
7+
"bearme": "cli.js"
8+
},
9+
"scripts": {
10+
"start": "budo index.js",
11+
"test": "node test.js"
12+
},
13+
"author": "Kyle Robinson Young <kyle@dontkry.com> (http://dontkry.com)",
14+
"license": "MIT"
15+
}

0 commit comments

Comments
 (0)