首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用yeoman搭建git-repo中包含的模板?

使用yeoman搭建git-repo中包含的模板?
EN

Stack Overflow用户
提问于 2016-02-03 18:23:40
回答 1查看 1.5K关注 0票数 1

有没有可能以某种方式创建一个yeoman生成器,简单地克隆一个指定的git-repo(和分支),然后删除.git?

或者我是不是搞错了..

基本上,我想实现的是在Windows或OSX中通过命令窗口实现的可能性。为了得到几个选项..基于所选的选项,我想克隆一个git存储库并签出一个特定的分支,然后删除.git以丢失git连接。

有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2016-02-13 04:50:22

下面是一个生成器,它使用Yeoman的api从远程获取GIT repos:

代码语言:javascript
复制
'use strict';

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


module.exports = generators.Base.extend({
  constructor: function () {
    generators.Base.apply(this, arguments);
  },

  // (1) Prompting
  prompting: function() {
    var done = this.async();
    this.prompt([{
      type: 'list',
      name: 'repo',
      message: 'Select a Repo',
      choices: [{
        name: 'Yeoman Generator Repo',
        value: 'generator'
      }, {
        name: 'Yeoman Yo Repo',
        value: 'yo'
      }]
    }], function (answers) {
      this.repo = answers.repo;
      done();
    }.bind(this));
  },

  // (2) Writing
  writing: function () {
    var done = this.async();
    this.remote('yeoman', this.repo, (err, remote) => {
      remote.bulkDirectory('.', this.repo);
      done();
    });  
  }
});

(1) Prompting,我们使用约曼的基本应用程序接口来提示用户输入。有关详细信息,请参阅Interacting with the user

(2) Writing,我们使用约曼的Github从remote()获取存储库,这是文档记录的here。正如您在文档中看到的,可选的第三个参数可能是分支的名称。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35174347

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档