【发布时间】:2014-06-14 14:40:24
【问题描述】:
我正在创建一个 yeoman 生成器来为项目制作一个简单的脚手架。
我想在项目中包含 sass bootstrap。
如何包含要注入的 sass bootstrap。
我有以下 index.js 来创建文件夹和文件结构表单 模板文件夹中的文件。
此示例使用 sass 文件,但我想包含 sass 引导程序,然后我会更改文件结构。
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var yosay = require('yosay');
var chalk = require('chalk');
var WordpresscdGenerator = yeoman.generators.Base.extend({
init: function () {
this.pkg = require('../package.json');
this.on('end', function () {
if (!this.options['skip-install']) {
this.installDependencies({
//install sass bootstrap
});
}
});
},
promptUser: function(){
var done = this.async();
console.log(this.yeoman);
var prompts = [{
name: 'appName',
message: 'What is the app called ?'
}];
this.prompt(prompts, function(props){
this.appName = props.appName;
done();
}.bind(this));
},
scaffoldFolder: function(){
this.mkdir('wp-content/themes/dist-theme');
this.mkdir('wp-content/themes/dev-theme');
this.mkdir('wp-content/themes/dev-theme/css');
this.mkdir('wp-content/themes/dev-theme/css/scss');
this.mkdir('wp-content/themes/dev-theme/fonts');
this.mkdir('wp-content/themes/dev-theme/images');
this.mkdir('wp-content/themes/dev-theme/js');
},
copyMainFiles: function(){
this.copy('_gruntfile.js', 'wp-content/themes/gruntfile.js');
this.copy('_package.json', 'wp-content/themes/package.json');
this.copy('_bower.json', 'wp-content/themes/bower.json');
//
this.copy('_base_defaults.scss','wp-content/themes/dev-theme/css/scss/_base_defaults.scss');
this.copy('_base_mixins.scss','wp-content/themes/dev-theme/css/scss/_base_mixins.scss');
this.copy('_base_reset.scss','wp-content/themes/dev-theme/css/scss/_base_reset.scss');
this.copy('_config.scss','wp-content/themes/dev-theme/css/scss/_config.scss');
this.copy('_main.scss','wp-content/themes/dev-theme/css/scss/_main.scss');
this.copy('styles.scss','wp-content/themes/dev-theme/css/scss/styles.scss');
this.copy('styles.css','wp-content/themes/dev-theme/css/styles.css');
this.copy('style.css','wp-content/themes/dev-theme/style.css');
this.copy('base.js','wp-content/themes/dev-theme/js/base.js');
this.copy('screenshot.png','wp-content/themes/dev-theme/screenshot.png');
this.copy('index.php', 'wp-content/themes/dev-theme/index.php');
this.copy('footer.php', 'wp-content/themes/dev-theme/footer.php');
this.copy('functions.php', 'wp-content/themes/dev-theme/functions.php');
this.copy('header.php', 'wp-content/themes/dev-theme/header.php');
this.copy('404.php', 'wp-content/themes/dev-theme/404.php');
//
var context = {
site_name: this.appName
};
}
});
module.exports = WordpresscdGenerator;
【问题讨论】: