Skip to content

Commit 1442372

Browse files
committed
feat: adding an easter egg for the tool.
1 parent 0b69491 commit 1442372

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

addon/ng2/commands/easter-egg.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import * as Command from 'ember-cli/lib/models/command';
2+
import * as Promise from 'ember-cli/lib/ext/promise';
3+
import * as chalk from 'chalk';
4+
5+
6+
function pickOne(of: string[]): string {
7+
return of[Math.floor(Math.random() * of.length)];
8+
}
9+
10+
11+
module.exports = function(name) {
12+
return Command.extend({
13+
name: name,
14+
works: 'insideProject',
15+
16+
run: function (commandOptions, rawArgs): Promise<void> {
17+
var stringUtils = require('ember-cli/lib/utilities/string');
18+
this[stringUtils.camelize(this.name)](commandOptions, rawArgs);
19+
20+
return Promise.resolve();
21+
},
22+
23+
makeThisAwesome: function() {
24+
const phrase = pickOne([
25+
`You're on it, there's nothing for me to do!`,
26+
`Let's take a look... nope, it's all good!`,
27+
`You're doing fine.`,
28+
`You're already doing great.`,
29+
`Nothing to do; already awesome. Exiting.`,
30+
`Error 418: As Awesome As Can Get.`
31+
]);
32+
console.log(chalk.green(phrase));
33+
}
34+
});
35+
};

addon/ng2/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ module.exports = {
1717
'doc': require('./commands/doc'),
1818
'github-pages-deploy': require('./commands/github-pages-deploy'),
1919

20-
// Configuration
20+
// Easter eggs.
21+
'make-this-awesome': require('./commands/easter-egg')('make-this-awesome'),
22+
23+
// Configuration.
2124
'set': require('./commands/set'),
2225
'get': require('./commands/get')
2326
};

tests/e2e/e2e_workflow.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,23 @@ describe('Basic end-to-end Workflow', function () {
300300
});
301301
});
302302

303+
it('Make this awesome', function (done) {
304+
this.timeout(420000);
305+
var called = false;
306+
var easterEgg = require('../../addon/ng2/commands/easter-egg')('make-this-awesome');
307+
var oldFn = easterEgg.makeThisAwesome;
308+
easterEgg.makeThisAwesome = function() {
309+
called = true;
310+
};
311+
312+
return ng(['make-this-awesome'])
313+
.then(function (str) {
314+
expect(called).to.be.equal(true);
315+
easterEgg.makeThisAwesome = oldFn;
316+
})
317+
.then(done);
318+
});
319+
303320
it('Turn on `noImplicitAny` in tsconfig.json and rebuild', function (done) {
304321
this.timeout(420000);
305322

0 commit comments

Comments
 (0)