当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Base.extend方法代码示例

本文整理汇总了TypeScript中yeoman-generator.Base.extend方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Base.extend方法的具体用法?TypeScript Base.extend怎么用?TypeScript Base.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yeoman-generator.Base的用法示例。


在下文中一共展示了Base.extend方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: require

/* tslint:disable:no-var-requires */
const generators = require("yeoman-generator");

module.exports = generators.Base.extend({
  install: {
    npm: function () {
      this.npmInstall();
    },
  },
  writing: function () {
    this.fs.copy(
      this.templatePath("**/*"),
      this.destinationPath(".")
    );
    this.fs.move(
      this.destinationPath("_gitignore"),
      this.destinationPath(".gitignore")
    );
    this.fs.move(
      this.destinationPath("_npmignore"),
      this.destinationPath(".npmignore")
    );
  },
});
开发者ID:mathiasringhof,项目名称:generator-typescript-npm,代码行数:24,代码来源:index.ts

示例2: require

///<reference path="typings/main.d.ts" />

var generators = require('yeoman-generator');

module.exports = generators.Base.extend({
    constructor: function() {
        generators.Base.apply(this,arguments);
        
        this.option
    } 
});
开发者ID:TheToolbox,项目名称:generator-openapi,代码行数:11,代码来源:index.ts

示例3: function

module.exports = YG.Base.extend({

    constructor: function (): void {
        YG.Base.apply(this, arguments);

        let self: GeneratorDrupal.Typed.IGenerator = this;

        self.option('use-npm-cache', {
            type: 'Boolean',
            desc: 'Adds "--cache-min 999999" option to `npm install`.',
            alias: null,
            'default': true,
            hide: false
        });

        self.config = {};

        self.appName2ModuleName = function (appName: string): string {
            return appName
                .replace(/^typed drupal /, '')
                .replace(' ', '_');
        };

        /**
         * @todo DRY - There is a same function in "project" generator.
         */
        self.destinationFileName = function (tplFileName: string): string {
            return tplFileName
                .replace(/\.ejs$/, '')
                .replace('moduleNameSnake', self.config.moduleNameSnake);
        };

        self.preProcessConfig = function (): void {
            self.config.moduleNameDash = self.config.moduleNameSnake.replace('_', '-');
            self.config.moduleNameLowerCamel = _.camelCase(self.config.moduleNameSnake);
            self.config.moduleNameUpperCamel = Utils.upperFirst(self.config.moduleNameLowerCamel);
        };

    },

    initializing: {
        welcomeMessage: function () : void {
            let self: GeneratorDrupal.Typed.IGenerator = this;

            self.log('Project template for TypeScript type definition');
        }
    },

    prompting: {
        base: function (): PromiseLike<any> {
            let self: GeneratorDrupal.Typed.IGenerator = this;

            return self
                .prompt([
                    {
                        type: 'input',
                        name: 'moduleNameSnake',
                        message: 'Machine-name of the Drupal module',
                        'default': self.appName2ModuleName(self.appname)
                    },
                    {
                        type: 'confirm',
                        name: 'runInstall',
                        message: 'Install NPM packages',
                        'default': false,
                        store: true
                    }
                ])
                .then(function (answers: GeneratorDrupal.Typed.IAnswers) : void {
                    self.config.moduleNameSnake = answers.moduleNameSnake;
                    self.config.runInstall = answers.runInstall;
                }.bind(this));
        }
    },

    configuring: {
        templateVariables: function (): void {
            let self: GeneratorDrupal.Typed.IGenerator = this;

            self.preProcessConfig();
        }
    },

    writing: {
        copyFiles: function (): void {
            let self: GeneratorDrupal.Typed.IGenerator = this;

            var files: string[] = [
                'source/moduleNameSnake.d.ts',
                'source/moduleNameSnake.t.ts',
                'source/tsconfig.json',
                '.editorconfig',
                '.gitignore',
                '.npmignore',
                'package.json',
                'README.md',
                'tslint.json',
                'typings.json'
            ];

//.........这里部分代码省略.........
开发者ID:Sweetchuck,项目名称:npm-generator-drupal,代码行数:101,代码来源:index.ts


注:本文中的yeoman-generator.Base.extend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。