I am trying to copy entire directories as part of a Yeoman generator. I have multiple functions that call this.fs.copy and it works as expected (for the most part) except fonts and assetsdev. I cannot figure out why assetsdev task copies the source folder into the fonts directory rather than into the root where I have specified. Here are my three functions that wholesale copy a directory:
this.props.dotDest = './';
this.props.srcPath = './assets-dev';
this.props.destPath = './public/assets';
dotfiles: function () { // Works as expected. Copies to the root.
this.fs.copy(
this.templatePath('dot_files/.*'),
this.destinationRoot(this.props.dotDest)
);
},
fonts: function () { // Works as expected. Copies to the bootstrap directory.
var done = this.async();
this.log( chalk.magenta.bold('Copying /fonts') );
this.fs.copy(
this.templatePath('fonts'),
this.destinationRoot(this.props.destPath + '/fonts/bootstrap')
)
done();
},
assetsdev: function () { // Does NOT work. Copies to the Bootstrap directory rather than the root.
var done = this.async();
this.log( chalk.magenta.bold('Copy assets-dev') );
this.fs.copy(
this.templatePath('assets-dev'),
this.destinationRoot(this.props.srcPath)
);
done();
},
I expect the resulting folder structure to be
-assets-dev
-public
-assets
-fonts
-bootstrap
-fontfile
-fontfile
-fontfile
But instead it's generating...
-public
-assets
-fonts
-bootstrap
-assets-dev
-fontfile
-fontfile
-fontfile
...and I can't figure out why. I even tried using the async() method in case it was running asynchronously and happened to be in that directory when the assetsdev function runs.
Does anyone know why assetsdev is copying to the wrong folder? I hope I have explained clearly enough. Thank you in advance!
So apparently I cant use destinationRoot(). Instead I have to use destinationPath(). I am not sure why but using destinationPath() copies correctly now.