Mercurial > repo
comparison bin/ello @ 4057:a7145daf0cdf
<mrhmouse> echo "#!/usr/bin/env node" > bin/ello
author | HackBot |
---|---|
date | Fri, 22 Nov 2013 15:56:34 +0000 |
parents | 4db1b679008d |
children | d6a049bf90e4 |
comparison
equal
deleted
inserted
replaced
4056:1edabb1df911 | 4057:a7145daf0cdf |
---|---|
1 #!/usr/bin/env node | 1 #!/usr/bin/env node |
2 | |
3 (function() { | |
4 var consonant_then_o, ends_with_consonant, ends_with_e, name; | |
5 | |
6 name = process.argv[2]; | |
7 | |
8 if (!(name != null ? name.length : void 0)) { | |
9 console.log('Usage: ello <name>'); | |
10 process.exit(); | |
11 } | |
12 | |
13 ends_with_e = /(.*)(e)$/i; | |
14 | |
15 consonant_then_o = /(.*)([bcdfghjklmnpqrstvwxz])([o0].*)/i; | |
16 | |
17 ends_with_consonant = /[bcdfghjklmnpqrstvwxz]/i; | |
18 | |
19 console.log(consonant_then_o.test(name) ? name.replace(consonant_then_o, function(match, before, consonant, rest) { | |
20 return before + consonant + 'ell' + rest; | |
21 }) : ends_with_e.test(name) ? name.replace(ends_with_e, function(match, before) { | |
22 return before + 'ello'; | |
23 }) : ends_with_consonant.test(name) ? name + 'ello' : "Hello, " + name + "!"); | |
24 | |
25 }).call(this); |