From 1da309ba2785894d5186b0d31ec456297c15050f Mon Sep 17 00:00:00 2001 From: goorockey Date: Tue, 30 Aug 2016 16:01:24 +0800 Subject: [PATCH] fix(cli): fix `completion` and `make-this-awesome` command invalid problem(#1889) --- .../commands/{completion.js => completion.ts} | 13 +++-- addon/ng2/commands/easter-egg.ts | 48 +++++++++---------- 2 files changed, 30 insertions(+), 31 deletions(-) rename addon/ng2/commands/{completion.js => completion.ts} (63%) diff --git a/addon/ng2/commands/completion.js b/addon/ng2/commands/completion.ts similarity index 63% rename from addon/ng2/commands/completion.js rename to addon/ng2/commands/completion.ts index 35f2a466df46..1c24bd3cbf5b 100644 --- a/addon/ng2/commands/completion.js +++ b/addon/ng2/commands/completion.ts @@ -1,11 +1,8 @@ -/*eslint-disable no-console */ -'use strict'; +const Command = require('ember-cli/lib/models/command'); +import * as path from 'path'; +import * as fs from 'fs'; -var Command = require('ember-cli/lib/models/command'); -var path = require('path'); -var fs = require('fs'); - -module.exports = Command.extend({ +const CompletionCommand = Command.extend({ name: 'completion', description: 'Adds autocomplete functionality to `ng` commands and subcommands', works: 'everywhere', @@ -16,3 +13,5 @@ module.exports = Command.extend({ console.log(scriptOutput); } }); + +export default CompletionCommand; diff --git a/addon/ng2/commands/easter-egg.ts b/addon/ng2/commands/easter-egg.ts index 59c1522f0e63..4aa1a01ae827 100644 --- a/addon/ng2/commands/easter-egg.ts +++ b/addon/ng2/commands/easter-egg.ts @@ -8,27 +8,27 @@ function pickOne(of: string[]): string { } -export default function(name: string) { - return Command.extend({ - name: name, - works: 'insideProject', - - run: function (commandOptions: any, rawArgs: string[]): Promise { - (this as any)[stringUtils.camelize(this.name)](commandOptions, rawArgs); - - return Promise.resolve(); - }, - - makeThisAwesome: function() { - const phrase = pickOne([ - `You're on it, there's nothing for me to do!`, - `Let's take a look... nope, it's all good!`, - `You're doing fine.`, - `You're already doing great.`, - `Nothing to do; already awesome. Exiting.`, - `Error 418: As Awesome As Can Get.` - ]); - console.log(chalk.green(phrase)); - } - }); -}; +const MakeThisAwesomeCommand = Command.extend({ + name: 'make-this-awesome', + works: 'insideProject', + + run: function (commandOptions: any, rawArgs: string[]): Promise { + (this as any)[stringUtils.camelize(this.name)](commandOptions, rawArgs); + + return Promise.resolve(); + }, + + makeThisAwesome: function() { + const phrase = pickOne([ + `You're on it, there's nothing for me to do!`, + `Let's take a look... nope, it's all good!`, + `You're doing fine.`, + `You're already doing great.`, + `Nothing to do; already awesome. Exiting.`, + `Error 418: As Awesome As Can Get.` + ]); + console.log(chalk.green(phrase)); + } +}); + +export default MakeThisAwesomeCommand;