Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我的约曼发电机赢了';不要复制文件_Javascript_Node.js_Yeoman_Yeoman Generator - Fatal编程技术网

Javascript 我的约曼发电机赢了';不要复制文件

Javascript 我的约曼发电机赢了';不要复制文件,javascript,node.js,yeoman,yeoman-generator,Javascript,Node.js,Yeoman,Yeoman Generator,我正在使用yeoman制作一个web应用程序,我一直在创建一个生成器。问题是它不会将文件复制到输出文件夹 这是我的密码: 'use strict'; var fs = require('fs'); var path = require('path'); var yeoman = require('yeoman-generator'); var yosay = require('yosay'); var chalk = require('chalk'); var wiredep = require

我正在使用yeoman制作一个web应用程序,我一直在创建一个生成器。问题是它不会将文件复制到输出文件夹

这是我的密码:

'use strict';
var fs = require('fs');
var path = require('path');
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');
var wiredep = require('wiredep');

module.exports=yeoman.extend({

  scaffoldFolders: function(){
      this.mkdir("app");
      this.mkdir("app/css");
      this.mkdir("app/sections");
      this.mkdir("build");
  },

  initializing: function(){
    this.pkg=require('../../package.json');
  },

  prompting: function() {
    var done = this.async();

    this.log(yosay(
      'Welcome to the marvelous ' + chalk.red('generator-palmyra') + ' generator!'
    ));

    var prompts = [{
       type: 'checkbox',
       name: 'mainframeworks',
       message:'Would you like AngularJS or JQuery ?',
       choices: [{
         name: 'Angular',
         value: 'includeAngular',
         checked: true
        }, {
         name: 'JQuery',
         value: 'includeJQuery',
         checked: true
        }]
      },
    {
       type: 'checkbox',
       name: 'features',
       message:'What more front-end frameworks would you like ?',
       choices: [{
         name: 'Sass',
         value: 'includeSass',
         checked: true
    }, {
        name: 'Bootstrap',
        value: 'includeBootstrap',
        checked: true
    }, {
        name: 'Modernizr',
        value: 'includeModernizr',
        checked: true
      }]
    }
  ];


  this.prompt(prompts, function (answers) {
  var features = answers.features;
  var mainframeworks = answers.mainframeworks;
  var hasFeature = function (feat) {
     return features.indexOf(feat) !== -1;
  };
  var hasMainframeworks = function (mainframework) {
     return mainframeworks.indexOf(mainframework) !== -1;
  };
// manually deal with the response, get back and store the results.
  this.includeSass = hasFeature('includeSass');
  this.includeBootstrap = hasFeature('includeBootstrap');
  this.includeModernizr = hasFeature('includeModernizr');
  this.includeAngular = hasMainframeworks('includeAngular');
  this.includeJQuery = hasMainframeworks('includeJQuery');
  done();
}.bind(this));
},



  writing() {

    gulpfile= function(){
    this.fs.copy(
      this.templatePath('gulpfile.js'),
      this.destinationPath('gulpfile.js')
                );
                        },
    packageJSON= function () {
      this.fs.copy(
    this.templatePath('_package.json'),
    this.destinationPath('package.json')
  );
                              },
    git= function () {
      this.fs.copy(
       this.templatePath('gitignore'),
       this.destinationPath('.gitignore')
                   );
      this.fs.copy(
      this.templatePath('gitattributes'),
      this.destinationPath('.gitattributes')
                   );
                     },
      bower= function () {
                          var bower = {
                            name: this._.slugify(this.appname),
                            private: true,
                            dependencies: {}
                          };
                          if (this.includeBootstrap) {
                            var bs = 'bootstrap' + (this.includeSass ? '-sass' : '');
                            bower.dependencies[bs] = '~3.3.1';
                          }
                          if (this.includeModernizr) {
                            bower.dependencies.modernizr = '~2.8.1';
                          }
                      if (this.includeAngular) {
                        bower.dependencies.angular = '~1.3.15';
                      }
                      if (this.includeJQuery) {
                        bower.dependencies.jquery = '~2.1.1';
                      }
                        this.fs.copy(
                            this.templatePath('bowerrc'),
                            this.destinationPath('.bowerrc')
                          );
                          this.write('bower.json', JSON.stringify(bower, null, 2));
                        },
      jshint= function () {
      this.fs.copy(
      this.templatePath('jshintrc'),
      this.destinationPath('.jshintrc')
                  );
                          },
     mainStylesheet= function () {
                             var css = 'main';
                             if (this.includeSass) {
                               css += '.scss';
                             } else {
                               css += '.css';
                             }
                         this.copy(css, 'app/styles/' + css);
                                 },
    writeIndex= function () {
                                 this.indexFile = this.src.read('index.html');
                                 this.indexFile = this.engine(this.indexFile, this);
                                 // wire Bootstrap plugins
                                 if (this.includeBootstrap) {
                                   var bs = '/bower_components/';
                                   if (this.includeSass) {
                                     bs += 'bootstrap-sass/assets/javascripts/bootstrap/';
                                   } else {
                                     bs += 'bootstrap/js/';
                                   }
                                   this.indexFile = this.appendScripts(this.indexFile, 'scripts/plugins.js', [
                                     bs + 'affix.js',
                                     bs + 'alert.js',
                                     bs + 'dropdown.js',
                                     bs + 'tooltip.js',
                                     bs + 'modal.js',
                                     bs + 'transition.js',
                                     bs + 'button.js',
                                     bs + 'popover.js',
                                     bs + 'carousel.js',
                                     bs + 'scrollspy.js',
                                     bs + 'collapse.js',
                                     bs + 'tab.js'
                                   ]);
                                 }
                                 this.indexFile = this.appendFiles({
                                   html: this.indexFile,
                                   fileType: 'js',
                                   optimizedPath: 'scripts/main.js',
                                   sourceFileList: ['scripts/main.js']
                                 });
                                 this.write('app/index.html', this.indexFile);
                               },
                               app= function () {
                               this.copy('main.js', 'app/scripts/main.js');
                               }
                             },
   install: function () {
    var howToInstall =
      '\nAfter running ' +
      chalk.yellow.bold('npm install & bower install') +
      ', inject your' +
      '\nfront end dependencies by running ' +
      chalk.yellow.bold('gulp wiredep') +
      '.';
    if (this.options['skip-install']) {
      this.log(howToInstall);
      return;
    }
    this.installDependencies();
    this.on('end', function () {
      var bowerJson = this.dest.readJSON('bower.json');
      // wire Bower packages to .html
      wiredep({
        bowerJson: bowerJson,
        directory: 'bower_components',
        exclude: ['bootstrap-sass', 'bootstrap.js'],
        ignorePath: /^(\.\.\/)*\.\./,
        src: 'app/index.html'
      });
      if (this.includeSass) {
        // wire Bower packages to .scss
        wiredep({
          bowerJson: bowerJson,
          directory: 'bower_components',
          ignorePath: /^(\.\.\/)+/,
          src: 'app/styles/*.scss'
        });
      }
    }.bind(this));
  }
});

我认为问题在于写作方法。我还想问下一步该去哪里?或者我是否通过了学习web开发的一个基本步骤如果你格式化代码,你会发现编写代码没有任何作用。它声明了一系列子函数,但不运行任何子函数

我认为问题是您想要一个对象,但却编写了一个函数:
writing(){}
而不是
writing:{}

我对代码进行了快速修复,但没有进行测试。因此可能会有进一步的语法问题,但大致应该是这样的:

“严格使用”;
var fs=需要('fs');
var path=require('path');
var yeoman=需要(“yeoman-generator”);
var yosay=需要('yosay');
var chalk=要求(“粉笔”);
var wiredep=require('wiredep');
module.exports=yeoman.extend({
脚手架文件夹:函数(){
这个.mkdir('app');
这个.mkdir('app/css');
本文件为mkdir(“应用程序/章节”);
这个.mkdir('build');
},
初始化:函数(){
this.pkg=require('../../package.json');
},
提示:函数(){
var done=this.async();
这个是.log(
吉赛(
“欢迎来到神奇世界”+
粉笔红('generator-palmyra')+
“发电机!”
)
);
变量提示=[
{
键入:“复选框”,
名称:'mainframes',
消息:“您想要AngularJS还是JQuery?”,
选择:[
{
名称:'Angular',
值:“includeAngular”,
核对:对,
},
{
名称:“JQuery”,
值:“includeJQuery”,
核对:对,
},
],
},
{
键入:“复选框”,
名称:“功能”,
信息:“您还需要什么样的前端框架?”,
选择:[
{
名称:'Sass',
值:“includeass”,
核对:对,
},
{
名称:'Bootstrap',
值:“includeBootstrap”,
核对:对,
},
{
名称:"现代化",,
值:“includemernizr”,
核对:对,
},
],
},
];
这是提示(
提示,
功能(答案){
var features=答案。特征;
var mainframes=answers.mainframes;
var hasFeature=功能(专长){
返回特征。indexOf(专长)!=-1;
};
var hasMainframeworks=函数(mainframework){
返回mainframeworks.indexOf(mainframework)!=-1;
};
//手动处理响应,返回并存储结果。
this.includeass=hasFeature('includeass');
this.includeBootstrap=hasFeature('includeBootstrap');
this.includemernizr=hasFeature('includemernizr');
this.includeAngular=hasMainframeworks('includeAngular');
this.includeJQuery=hasMainframeworks('includeJQuery');
完成();
}.绑定(此)
);
},
写作:{
gulpfile:function(){
这是我的复印件(
this.templatePath('gulpfile.js'),
this.destinationPath('gulpfile.js')
);
},
packageJSON:function(){
这是我的复印件(
这个.templatePath(“u package.json”),
this.destinationPath('package.json')
);
},
git:function(){
这是我的复印件(
this.templatePath('gitignore'),
此.destinationPath('.gitignore'))
);
这是我的复印件(
这个.templatePath('gittributes'),
此.destinationPath(“.gittributes”)
);
},
鲍尔:函数(){
var bower={
名称:this.\u.slugify(this.appname),
二等兵:是的,
依赖项:{},
};
如果(此。includeBootstrap){
var bs='bootstrap'+(this.includeass?'-sass':'');
依赖关系[bs]='~3.3.1';
}
if(this.includemernizr){
bower.dependencies.modernizer='~2.8.1';
}
如果(包括非英语){
bower.dependencies.angular='~1.3.15';
}
if(this.includeJQuery){
bower.dependencies.jquery='~2.1.1';
}
this.fs.copy(this.templatePath('bowerrc')、this.destinationPath('.bowerrc');
this.write('bower.json',json.stringify(bower,null,2));
},
jshint:function(){
这是我的复印件(
this.templatePath('jshintrc'),
this.destinationPath('.jshintrc'))
);
},
主样式表:函数(){
var css='main';
如果(本条包括在内){
css+='.scss';
}否则{
css+='.css';
}
这个.copy(css,“app/styles/”+css);
},
writeIndex:函数(){
this.indexFile=this.src.read('index.html');
这个是indexFi