本文整理汇总了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")
);
},
});
示例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
}
});
示例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'
];
//.........这里部分代码省略.........