Reputation: 216
I just started using the amazing yeoman.io generators. Everything was working great, up until I tried to scaffold whole directores. Somehow, this.directory, this.bulkDirectory etc. aren't working. I'm not receieving any errors, nothing copies (while this.bulkCopy does work and gives success message).
Inside the copyMainFiles function, I actually want to copy a complete directory with files to the specified locations. I'm not really looking forward to manually this.copy every file.
In short: this.directory, this.bulkDirectory and this.copy are not working. this.bulkCopy IS working.
This is de index.js (stripped), I hope someone knows what goes wrong. Yeoman version: 1.4.6
'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var NulvijftigGenerator = yeoman.generators.Base.extend({
promptUser: function() {
var done = this.async();
// have Yeoman greet the user
console.log('asasd');
var prompts = [{
name: 'appName',
message: 'Blablabla'
}];
this.prompt(prompts, function (props) {
this.appName = props.appName;
this.folderName = props.folderName;
this.templateType = props.templateType;
this.plugins = props.plugins;
/* this.addDemoSection = props.addDemoSection; */
done();
}.bind(this));
},
scaffoldFolders: function(){
// if the user selected basic webshop, create the required folders
if(this.templateType == "extrawebshop"){
// main folder (frontend value in configuration)
this.mkdir(this.folderName);
this.mkdir(this.folderName + "/account");
}
if(this.templateType == "basicwebsite"){
// main folder (frontend value in configuration)
this.mkdir(this.folderName);
}
},
copyMainFiles: function(){
// if the user selected basic webshop, copy the required files
if(this.templateType == "basicwebsite"){
this.directory("basicwebsite", this.folderName);
}
var context = {
site_name: this.appName
};
//this.template("_header.html", "app/header.html", context);
},
runNpm: function(){
var done = this.async();
this.npmInstall("", function(){
console.log("\nEverything Setup !!!\n");
done();
});
}
});
module.exports = NulvijftigGenerator;
Upvotes: 1
Views: 3234
Reputation: 8376
I'm not quite sure why your config doesn't work, but, taking it simpler, there are few things to consider:
this.directory
actually works,this.sourcePath()
and this.destinationPath()
respectively.So, if you're having, say, folder structure like
..
templates
src
sass
jsx
dist
css
js
html
then simple
writing: {
app: function() {
this.directory('src', 'src');
this.directory('dist', 'dist');
}
}
should work.
But!
The directory is being copied recursively only if there is at least one file within its full recursive path. On the other hand, I'm not sure if it's necessary (and doesn't really overcomplicate things) to copy empty folders structure.
Upvotes: 3
Reputation: 10761
In your project you have a Gruntfile.js
.
In this file you have some copy tasks. You can change this for your needs.
For example I added a custom task in my project for copying language files:
copy: {
dist: {
files: [{
expand: true,
cwd: 'app/assets/lang/',
src: ['**'],
dest: '<%= config.dist %>/assets/lang/'
}
----more code----
Edit: After reading your comment, maybe I didn't understand your question.
Upvotes: 1
Reputation: 535
Go to your grunt script in yeoman project and there look for css and js folder paths . There add your own custom folder you want to copy.
Upvotes: 0