• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript command.extend函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript project.nullProject函数代码示例发布时间:2022-05-25
下一篇:
TypeScript promise.resolve函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap