當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。