Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite9a0aac

Browse files
author
Benjamin Coe
committed
initial commit
0 parents  commite9a0aac

File tree

10 files changed

+180
-0
lines changed

10 files changed

+180
-0
lines changed

‎.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015"]
3+
}

‎.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
lib
3+
.nyc_output
4+
node_modules

‎LICENSE.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright (c) 2015, Contributors
2+
3+
Permission to use, copy, modify, and/or distribute this software
4+
for any purpose with or without fee is hereby granted, provided
5+
that the above copyright notice and this permission notice
6+
appear in all copies.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
10+
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
11+
LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
12+
OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
13+
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
14+
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

‎README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#Yarsay
2+
3+
>Hello Joe! tell Pirate Joe what to say.
4+
5+
Inspired by[yosay](https://github.com/yeoman/yosay), which was in turn inspired by[cowsay](https://en.wikipedia.org/wiki/Cowsay).
6+
7+
[![Build Status](https://travis-ci.org/bcoe/yarsay.png)](https://travis-ci.org/bcoe/yarsay)
8+
[![Coverage Status](https://coveralls.io/repos/bcoe/yarsay/badge.svg?branch=)](https://coveralls.io/r/bcoe/yarsay?branch=)
9+
[![NPM version](https://img.shields.io/npm/v/yarsay.svg)](https://www.npmjs.com/package/yarsay)
10+
11+
<imgwidth="500"src="screen.png">
12+
13+
##Usage
14+
15+
```sh
16+
yarsay"Hello World!"
17+
```
18+
19+
Or,
20+
21+
```sh
22+
echo"Hello World"| yarsay
23+
```
24+
25+
Or,
26+
27+
```js
28+
var yarsay=require('./lib/yarsay')
29+
yarsay('Hello World!').say()
30+
```
31+
32+
##License
33+
34+
ISC

‎joe.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
  @88@ 
2+
 0CG8 
3+
80GGCCGG8@ @GLLL0@ 
4+
@8Cft111111tfG8 8GLLLL0@ 
5+
@Gt111111111111fG@ @0CLLL@ 
6+
8G11111111111111110 0LLL@ 
7+
@Gfttt1t11tttffLttt1fG0 @LLL@ 
8+
8GL11ffftf111if880GCGftf0@ @CLG@ 
9+
f111tfCCf1;;;1G80GtL8LLLG@ 8LL0@ 
10+
GCGLttfC88GCG000080088CC0@ 80LGG8 
11+
@GffC80fLGCCGG80CfGCG@ @GLfCG8 
12+
808888GLtttffftLG00@@ @C111f@ 
13+
@@80GGGCG8@ @C111t@ 
14+
80GLLLG880CCCG08@ 8f111t@ 
15+
@0CftttttfC0Lt1ttttLG8 8t111f@ 
16+
@Gt11tttt11tCt1tttt11tL08t111L@ 

‎package.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name":"yarsay",
3+
"version":"1.0.0",
4+
"description":"Tell Pirate Joe what to say",
5+
"main":"lib/yarsay.js",
6+
"bin":"lib/cli.js",
7+
"scripts": {
8+
"build":"cd src; babel ./*.js -d ../lib",
9+
"prepublish":"npm run build",
10+
"pretest":"standard ./src/*.js",
11+
"test":"nyc --require babel-core/register mocha"
12+
},
13+
"keywords": [
14+
"yargs",
15+
"cli",
16+
"yarsay",
17+
"pirate",
18+
"talk"
19+
],
20+
"author":"Ben Coe <ben@npmjs.com>",
21+
"license":"ISC",
22+
"devDependencies": {
23+
"babel-cli":"^6.2.0",
24+
"babel-core":"^6.2.1",
25+
"babel-preset-es2015":"^6.1.18",
26+
"chai":"^3.4.1",
27+
"mocha":"^2.3.4",
28+
"standard":"^5.4.1"
29+
},
30+
"dependencies": {
31+
"bluebird":"^3.0.5",
32+
"chalk":"^1.1.1",
33+
"cliui":"^3.1.0",
34+
"get-stdin":"^5.0.1",
35+
"window-size":"^0.1.4",
36+
"yargs":"^3.30.0"
37+
}
38+
}

‎screen.png

147 KB
Loading

‎src/cli.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
if(typeofGLOBAL.Promise==='undefined')GLOBAL.Promise=require('bluebird')
2+
3+
varYarsay=require('./yarsay')
4+
varargv=require('yargs')
5+
.usage('$0 <msg>\necho <msg> | $0')
6+
.version(require('../package.json').version,'v')
7+
.help('h')
8+
.alias('help','h')
9+
.alias('v','version')
10+
.example('$0 "Hello Joe"')
11+
.example('echo "Hello Joe" | $0')
12+
.argv
13+
constgetStdin=require('get-stdin')
14+
15+
getStdin().then(str=>{
16+
varyarsay=null
17+
18+
if(str)yarsay=Yarsay(str)
19+
elseif(argv._.length)yarsay=Yarsay(argv._.join(' '))
20+
elseyarsay=Yarsay()
21+
22+
yarsay.say()
23+
})

‎src/yarsay.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
varchalk=require('chalk')
2+
varfs=require('fs')
3+
varws=require('window-size')
4+
varui=require('cliui')({
5+
width:Math.min(ws.width||60,60)
6+
})
7+
8+
classYarsay{
9+
constructor(msg="maybe if we ask nicely, they'll just give us their riffiwobbles!"+chalk.bold(' --Pirate Joe, the eternal optimist...')){
10+
varjoe=fs.readFileSync('./joe.txt','utf-8')
11+
12+
// the layout engine treats Joe as one
13+
// giant pirate-shaped word.
14+
joe=joe.replace(//g,'_')
15+
16+
ui.div({
17+
text:joe.split('\n').join(''),
18+
width:35,
19+
padding:[0,0,0,0]
20+
},{
21+
text:msg,
22+
border:true,
23+
padding:[3,0,0,0]
24+
})
25+
26+
this.message=ui.toString().replace(/_/g,' ')
27+
}
28+
29+
say(){
30+
console.log(this.message)
31+
}
32+
}
33+
34+
module.exports=function(msg){
35+
returnnewYarsay(msg)
36+
}

‎test/yarsay.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* global describe, it */
2+
3+
varYarsay=require('../src/yarsay')
4+
5+
require('chai').should()
6+
7+
describe('Yarsay',function(){
8+
it('defaults to riffiwobbles',function(){
9+
varyarsay=Yarsay()
10+
yarsay.message.should.include('riffiwobbles')
11+
})
12+
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp