Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to preserve file mode on method actions.template #474

Merged
merged 1 commit into from Jan 19, 2014

Conversation

ruyadorno
Copy link
Contributor

Added the ability to preserve file mode on method actions.template

Fixes #464

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 63d8abf on ruyadorno:iss-464 into * on yeoman:master*.

this.checkForCollision(filepath, content, function (err, config) {
if (err) {
config.callback(err);
return this.emit('error', err);
}

var fileOptions = {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code will be cleaner if you accept a writeFile option hash as third parameter rather than only the file mode.

@SBoudrias
Copy link
Member

Hey Ruy, thanks for taking time to handle this issue!

On the concept though, I don't believe we should replicate the same permissions from the file inside the source directory. This will break for people relying on correctly setup machine with umask and set group id permissions.

Rather, I believe we should only replicate the executable bits. (ogw+x)

@SBoudrias
Copy link
Member

I though about it a little more, and maybe permissions issues aren't going to be a problem after all. I've been working on File-utils (instantiated as the new this.src and this.dest) to resolve similar issue, and I've come to believe it didn't really matter that we just keep the exec bit. umask and ownership will still be handled globally by the system only the chmod will change; which seems OK to me.

Worst case scenario, we'll update if people got some issues with his.

So, just fix the method to take an option hash and we'll be good to merge.

@ruyadorno
Copy link
Contributor Author

Great! Thanks for taking the time to review this too! I honestly haven't thought through all possible permission issues but great to see that it will eventually make it to the code :)

I'll send the commit fixing the option.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 9fc8d24 on ruyadorno:iss-464 into d023ead on yeoman:master.

@@ -201,6 +201,7 @@ describe('yeoman.generators.Base', function () {
describe('without options', function () {
before(function (done) {
this.dummy.foo = 'fooooooo';
this.dummy.template('foo.js', 'write/to/from-foo.js');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you instead writeFileSync this file with a file mode that you wouldn't usually found ? (e.g. parseInt(337, 8)).

@SBoudrias
Copy link
Member

LGTM, can you squash your commits together and rebase on latest master? (writeFileSync in Node 0.8 will throw as it doesn't expect a config object as third parameter, and we just removed our support for 0.8)

@ruyadorno
Copy link
Contributor Author

Ok, I changed the test file to look like what you've said, only thing that is bothering me is that this test is kind of looking different from all the other ones who uses files already present on fixtures folder.

Also I had to dispose of the file after... tell me what you think, if everything is good I'll look into squashing the commits

@@ -201,9 +201,10 @@ actions.read = function read(filepath, encoding) {
*
* @param {String} filepath
* @param {String} content
* @param {String} writeFile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be an object ;) Maybe add a link to Node.js writeFile documentation.

@ruyadorno
Copy link
Contributor Author

I just pushed the squashed commits rebased after the latest master, let me know if it is good

@SBoudrias
Copy link
Member

Perfect, thanks a lot! :shipit:

SBoudrias added a commit that referenced this pull request Jan 19, 2014
Added the ability to preserve file mode on method actions.template
@SBoudrias SBoudrias merged commit 2c0116d into yeoman:master Jan 19, 2014
@ruyadorno ruyadorno deleted the iss-464 branch January 19, 2014 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keep file mode on template
3 participants