4049
|
1 #!/usr/bin/env node
|
4070
|
2 // Generated by CoffeeScript 1.6.2
|
4067
|
3 (function() {
|
4070
|
4 var consonant_then_o, ell_manglable, ends_with_consonant, ends_with_consonant_then_vowel, name, starts_with_o;
|
4067
|
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 consonant_then_o = /(.*)([bcdfghjklmnpqrstvwxz])([o0].*)/i;
|
|
14
|
|
15 ends_with_consonant = /[bcdfghjklmnpqrstvwxz]$/i;
|
|
16
|
4070
|
17 ends_with_consonant_then_vowel = /(.*[bcdfghjklmnpqrstvwxz])[aeiouy]+$/i;
|
|
18
|
4067
|
19 starts_with_o = /[o0]/i;
|
|
20
|
4070
|
21 ell_manglable = /(.*)(el+[aeiouy]+)(.*)/i;
|
|
22
|
4067
|
23 console.log(consonant_then_o.test(name) ? name.replace(consonant_then_o, function(match, before, consonant, rest) {
|
|
24 return before + consonant + 'ell' + rest;
|
4070
|
25 }) : ell_manglable.test(name) ? name.replace(ell_manglable, function(match, before, middle, rest) {
|
|
26 return before + 'ello' + rest;
|
|
27 }) : starts_with_o.test(name) ? 'hell' + name : ends_with_consonant_then_vowel.test(name) ? name.replace(ends_with_consonant_then_vowel, function(match, before) {
|
4067
|
28 return before + 'ello';
|
|
29 }) : ends_with_consonant.test(name) ? name + 'ello' : "Hello, " + name + "!");
|
|
30
|
|
31 }).call(this); |