當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript command.extend函數代碼示例

本文整理匯總了TypeScript中ember-cli/lib/models/command.extend函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript extend函數的具體用法?TypeScript extend怎麽用?TypeScript extend使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了extend函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

module.exports = function(name) {
  return Command.extend({
    name: name,
    works: 'insideProject',

    run: function (commandOptions, rawArgs): Promise<void> {
      var stringUtils = require('ember-cli/lib/utilities/string');
      this[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));
    }
  });
};
開發者ID:Bigous,項目名稱:angular-cli,代碼行數:25,代碼來源:easter-egg.ts

示例2: function

export default function(name: string) {
  return Command.extend({
    name: name,
    works: 'insideProject',

    run: function (commandOptions: any, rawArgs: string[]): Promise<void> {
      (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));
    }
  });
};
開發者ID:StudioProcess,項目名稱:angular-cli,代碼行數:24,代碼來源:easter-egg.ts

示例3: SilentError

const NewCommand = Command.extend({
  name: 'new',
  description: `Creates a new directory and runs ${chalk.green('ng init')} in it.`,
  works: 'outsideProject',

  availableOptions: [
    { name: 'dry-run', type: Boolean, default: false, aliases: ['d'] },
    { name: 'verbose', type: Boolean, default: false, aliases: ['v'] },
    { name: 'link-cli', type: Boolean, default: false, aliases: ['lc'] },
    { name: 'skip-npm', type: Boolean, default: false, aliases: ['sn'] },
    { name: 'skip-bower', type: Boolean, default: true, aliases: ['sb'] },
    { name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] },
    { name: 'directory', type: String, aliases: ['dir'] },
    { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] },
    { name: 'style', type: String, default: 'css' },
    { name: 'prefix', type: String, default: 'app', aliases: ['p'] },
    { name: 'mobile', type: Boolean, default: false },
    { name: 'routing', type: Boolean, default: false },
    { name: 'inline-style', type: Boolean, default: false, aliases: ['is'] },
    { name: 'inline-template', type: Boolean, default: false, aliases: ['it'] }
  ],

  run: function (commandOptions: any, rawArgs: string[]) {
    const packageName = rawArgs.shift();

    if (!packageName) {
      return Promise.reject(new SilentError(
        `The "ng ${this.name}" command requires a name argument to be specified. ` +
        `For more details, use "ng help".`));
    }

    commandOptions.name = packageName;
    if (commandOptions.dryRun) {
      commandOptions.skipGit = true;
    }

    if (packageName === '.') {
      return Promise.reject(new SilentError(
        `Trying to generate an application structure in this directory? Use "ng init" ` +
        `instead.`));
    }

    if (!validProjectName(packageName)) {
      return Promise.reject(
        new SilentError(`We currently do not support a name of "${packageName}".`));
    }

    if (commandOptions.mobile) {
      return Promise.reject(new SilentError(
        'The --mobile flag has been disabled temporarily while we await an update of ' +
        'angular-universal for supporting NgModule. Sorry for the inconvenience.'
      ));
    }

    if (!commandOptions.directory) {
      commandOptions.directory = packageName;
    }

    const createAndStepIntoDirectory =
      new this.tasks.CreateAndStepIntoDirectory({ ui: this.ui, analytics: this.analytics });

    const initCommand = new InitCommand({
      ui: this.ui,
      analytics: this.analytics,
      tasks: this.tasks,
      project: Project.nullProject(this.ui, this.cli)
    });

    return createAndStepIntoDirectory
      .run({
        directoryName: commandOptions.directory,
        dryRun: commandOptions.dryRun
      })
      .then(initCommand.run.bind(initCommand, commandOptions, rawArgs));
  }
});
開發者ID:JasonGoemaat,項目名稱:angular-cli,代碼行數:76,代碼來源:new.ts

示例4: function

const VersionCommand = Command.extend({
  name: 'version',
  description: 'outputs angular-cli version',
  aliases: ['v', '--version', '-v'],
  works: 'everywhere',

  availableOptions: [
    { name: 'verbose', type: Boolean, 'default': false }
  ],

  run: function(options) {
    var versions = process.versions;
    var pkg = require(path.resolve(__dirname, '..', '..', '..', 'package.json'));

    versions['os'] = process.platform + ' ' + process.arch;

    var alwaysPrint = ['node', 'os'];

    this.printVersion('angular-cli', pkg.version);

    for (var module in versions) {
      if (options.verbose || alwaysPrint.indexOf(module) > -1) {
        this.printVersion(module, versions[module]);
      }
    }
  },

  printVersion: function(module, version) {
    this.ui.writeLine(module + ': ' + version);
  }
});
開發者ID:Sundar-Natarajan,項目名稱:angular-cli,代碼行數:31,代碼來源:version.ts

示例5: Promise

import * as chalk from 'chalk';
import * as Command from 'ember-cli/lib/models/command';
import {CliConfig} from '../models/config';


const GetCommand = Command.extend({
  name: 'get',
  description: 'Get a value from the configuration.',
  works: 'everywhere',

  availableOptions: [],

  run: function (commandOptions, rawArgs): Promise<void> {
    return new Promise(resolve => {
      const value = new CliConfig().get(rawArgs[0]);
      if (value === null) {
        console.error(chalk.red('Value cannot be found.'));
      } else if (typeof value == 'object') {
        console.log(JSON.stringify(value));
      } else {
        console.log(value);
      }
      resolve();
    });
  }
});

module.exports = GetCommand;
開發者ID:2blessed2bstressedbythedevilsmess,項目名稱:angular-cli,代碼行數:28,代碼來源:get.ts

示例6: function

import * as Command from 'ember-cli/lib/models/command';
import * as DocTask from '../tasks/doc';

const DocCommand = Command.extend({
  name: 'doc',
  description: 'Opens the official Angular documentation for a given keyword.',
  works: 'everywhere',

  anonymousOptions: [
    '<keyword>'
  ],

  run: function(commandOptions, rawArgs:Array<string>) {
    var keyword = rawArgs[0];
    
    var docTask = new DocTask({
      ui: this.ui,
      analytics: this.analytics,
      project: this.project
    });

    return docTask.run(keyword);
  }
});

module.exports = DocCommand;
開發者ID:2blessed2bstressedbythedevilsmess,項目名稱:angular-cli,代碼行數:26,代碼來源:doc.ts

示例7: WebpackBuildWatch

module.exports = Command.extend({
  name: 'build',
  description: 'Builds your app and places it into the output path (dist/ by default).',
  aliases: ['b'],

  availableOptions: [
    { name: 'environment',    type: String,  default: 'development', aliases: ['e', { 'dev': 'development' }, { 'prod': 'production' }] },
    { name: 'output-path',    type: 'Path',  default: 'dist/',       aliases: ['o'] },
    { name: 'watch',          type: Boolean, default: false,         aliases: ['w'] },
    { name: 'watcher',        type: String },
    { name: 'suppress-sizes', type: Boolean, default: false },

    // Experimental webpack build for material team
    { name: 'm2', type: Boolean, default: false}
  ],

  run: function (commandOptions: BuildOptions) {
    var project = this.project;
    var ui = this.ui;
    var buildTask = commandOptions.watch ?
      new WebpackBuildWatch({
        cliProject: project,
        ui: ui,
        outputPath: commandOptions.outputPath,
        environment: commandOptions.environment
      }) :
      new WebpackBuild({
        cliProject: project,
        ui: ui,
        outputPath: commandOptions.outputPath,
        environment: commandOptions.environment
      });

    console.log(buildTask);

    return buildTask.run(commandOptions);
  }
});
開發者ID:TheLarkInn,項目名稱:angular-cli,代碼行數:38,代碼來源:build.ts

示例8: checkForPendingChanges

module.exports = Command.extend({
  name: 'github-pages:deploy',
  aliases: ['gh-pages:deploy'],
  description: 'Build the test app for production, commit it into a git branch, setup GitHub repo and push to it',
  works: 'insideProject',

  availableOptions: [
    {
      name: 'message',
      type: String,
      default: 'new gh-pages version',
      description: 'The commit message to include with the build, must be wrapped in quotes.'
    }, {
      name: 'environment',
      type: String,
      default: 'production',
      description: 'The Angular environment to create a build for'
    }, {
      name: 'branch',
      type: String,
      default: 'gh-pages',
      description: 'The git branch to push your pages to'
    }, {
      name: 'skip-build',
      type: Boolean,
      default: false,
      description: 'Skip building the project before deploying'
    }, {
      name: 'gh-token',
      type: String,
      default: '',
      description: 'Github token'
    }, {
      name: 'gh-username',
      type: String,
      default: '',
      description: 'Github username'
    }],

  run: function(options, rawArgs) {
    var ui = this.ui;
    var root = this.project.root;
    var execOptions = {
      cwd: root
    };
    var projectName = this.project.pkg.name;

    let initialBranch;

    // declared here so that tests can stub exec
    const execPromise = Promise.denodeify(exec);

    var buildTask = new BuildTask({
      ui: this.ui,
      analytics: this.analytics,
      project: this.project
    });

    var buildOptions = {
      environment: options.environment,
      outputPath: 'dist/'
    };

    var createGithubRepoTask = new CreateGithubRepo({
      ui: this.ui,
      analytics: this.analytics,
      project: this.project
    });

    var createGithubRepoOptions = {
      projectName,
      ghUsername: options.ghUsername,
      ghToken: options.ghToken
    };

    return checkForPendingChanges()
      .then(build)
      .then(saveStartingBranchName)
      .then(createGitHubRepoIfNeeded)
      .then(checkoutGhPages)
      .then(copyFiles)
      .then(updateBaseHref)
      .then(addAndCommit)
      .then(returnStartingBranch)
      .then(pushToGitRepo)
      .then(printProjectUrl);

    function checkForPendingChanges() {
      return execPromise('git status --porcelain')
        .then(stdout => {
          if (/\w+/m.test(stdout)) {
            let msg = 'Uncommitted file changes found! Please commit all changes before deploying.';
            return Promise.reject(new SilentError(msg));
          }
        });
    }

    function build() {
      if (options.skipBuild) return Promise.resolve();
      return win.checkWindowsElevation(ui)
//.........這裏部分代碼省略.........
開發者ID:DrMabuse23,項目名稱:angular-cli,代碼行數:101,代碼來源:github-pages-deploy.ts

示例9: require

const Command = require('ember-cli/lib/models/command');
import {E2eTask} from '../tasks/e2e';
import {CliConfig} from '../models/config';

const E2eCommand = Command.extend({
  name: 'e2e',
  description: 'Run e2e tests in existing project',
  works: 'insideProject',
  run: function () {
    this.project.ngConfig = this.project.ngConfig || CliConfig.fromProject();

    const e2eTask = new E2eTask({
      ui: this.ui,
      analytics: this.analytics,
      project: this.project
    });

    return e2eTask.run();
  }
});


export default E2eCommand;
開發者ID:JasonGoemaat,項目名稱:angular-cli,代碼行數:23,代碼來源:e2e.ts

示例10: Promise

import * as Command from 'ember-cli/lib/models/command';
import {CliConfig} from '../models/config';


const SetCommand = Command.extend({
  name: 'set',
  description: 'Set a value in the configuration.',
  works: 'outsideProject',

  availableOptions: [
    { name: 'global', type: Boolean, default: false, aliases: ['g'] },
  ],

  run: function (commandOptions, rawArgs): Promise<void> {
    return new Promise(resolve => {
      const config = new CliConfig();
      config.set(rawArgs[0], rawArgs[1], commandOptions.force);
      config.save();
      resolve();
    });
  }
});

module.exports = SetCommand;
module.exports.overrideCore = true;
開發者ID:danielsef,項目名稱:angular-cli,代碼行數:25,代碼來源:set.ts


注:本文中的ember-cli/lib/models/command.extend函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。