Merge pull request #227 from rezonant/feat-multisymbolic

Fixes an issue with multi-symbolic mode specification (ie a-rwx,u+rw)
This commit is contained in:
Artur Adib 2015-08-29 16:03:44 -04:00
commit e05ca3f8c4
2 changed files with 52 additions and 1 deletions

View File

@ -185,6 +185,7 @@ function _chmod(options, mode, filePattern) {
log(file + ' -> ' + newPerms.toString(8));
}
fs.chmodSync(file, newPerms);
perms = newPerms; // for the next round of changes!
}
}
else {

View File

@ -77,4 +77,54 @@ assert.equal(fs.statSync('resources/chmod/b/a').mode & parseInt('700', 8), parse
shell.chmod('-R', 'u+w', 'resources/chmod/a/b');
fs.unlinkSync('resources/chmod/a/b/c/link');
shell.exit(123);
// Test combinations
shell.chmod('a-rwx', 'resources/chmod/file1');
assert.equal(fs.statSync('resources/chmod/file1').mode & parseInt('000', 8), parseInt('000', 8));
shell.chmod('644', 'resources/chmod/file1');
shell.chmod('a-rwx,u+r', 'resources/chmod/file1');
assert.equal(fs.statSync('resources/chmod/file1').mode & parseInt('400', 8), parseInt('400', 8));
shell.chmod('644', 'resources/chmod/file1');
shell.chmod('a-rwx,u+rw', 'resources/chmod/file1');
assert.equal(fs.statSync('resources/chmod/file1').mode & parseInt('600', 8), parseInt('600', 8));
shell.chmod('644', 'resources/chmod/file1');
shell.chmod('a-rwx,u+rwx', 'resources/chmod/file1');
assert.equal(fs.statSync('resources/chmod/file1').mode & parseInt('700', 8), parseInt('700', 8));
shell.chmod('644', 'resources/chmod/file1');
shell.chmod('000', 'resources/chmod/file1');
shell.chmod('u+rw', 'resources/chmod/file1');
assert.equal(fs.statSync('resources/chmod/file1').mode & parseInt('600', 8), parseInt('600', 8));
shell.chmod('644', 'resources/chmod/file1');
shell.chmod('000', 'resources/chmod/file1');
shell.chmod('u+wx', 'resources/chmod/file1');
assert.equal(fs.statSync('resources/chmod/file1').mode & parseInt('300', 8), parseInt('300', 8));
shell.chmod('644', 'resources/chmod/file1');
shell.chmod('000', 'resources/chmod/file1');
shell.chmod('u+r,g+w,o+x', 'resources/chmod/file1');
assert.equal(fs.statSync('resources/chmod/file1').mode & parseInt('421', 8), parseInt('421', 8));
shell.chmod('644', 'resources/chmod/file1');
shell.chmod('000', 'resources/chmod/file1');
shell.chmod('u+rw,g+wx', 'resources/chmod/file1');
assert.equal(fs.statSync('resources/chmod/file1').mode & parseInt('630', 8), parseInt('630', 8));
shell.chmod('644', 'resources/chmod/file1');
shell.chmod('700', 'resources/chmod/file1');
shell.chmod('u-x,g+rw', 'resources/chmod/file1');
assert.equal(fs.statSync('resources/chmod/file1').mode & parseInt('660', 8), parseInt('660', 8));
shell.chmod('644', 'resources/chmod/file1');
shell.chmod('a-rwx,u+rw', 'resources/chmod/file1');
assert.equal(fs.statSync('resources/chmod/file1').mode & parseInt('600', 8), parseInt('600', 8));
shell.chmod('a-rwx,u+rw', 'resources/chmod/file1');
assert.equal(fs.statSync('resources/chmod/file1').mode & parseInt('600', 8), parseInt('600', 8));
shell.chmod('644', 'resources/chmod/file1');
shell.exit(123);