зеркало из https://github.com/microsoft/shelljs.git
Merge pull request #228 from rezonant/feat-capitalX
feat-multisymbolic + Support for directory entry (capital X in chmod terms)
This commit is contained in:
Коммит
a38ef4557e
18
src/chmod.js
18
src/chmod.js
|
@ -114,7 +114,9 @@ function _chmod(options, mode, filePattern) {
|
|||
return;
|
||||
}
|
||||
|
||||
var perms = fs.statSync(file).mode;
|
||||
var stat = fs.statSync(file);
|
||||
var isDir = stat.isDirectory();
|
||||
var perms = stat.mode;
|
||||
var type = perms & PERMS.TYPE_MASK;
|
||||
|
||||
var newPerms = perms;
|
||||
|
@ -135,11 +137,15 @@ function _chmod(options, mode, filePattern) {
|
|||
var changeGroup = applyTo.indexOf('g') != -1 || applyTo === 'a' || applyTo === '';
|
||||
var changeOther = applyTo.indexOf('o') != -1 || applyTo === 'a' || applyTo === '';
|
||||
|
||||
var changeRead = change.indexOf('r') != -1;
|
||||
var changeWrite = change.indexOf('w') != -1;
|
||||
var changeExec = change.indexOf('x') != -1;
|
||||
var changeSticky = change.indexOf('t') != -1;
|
||||
var changeSetuid = change.indexOf('s') != -1;
|
||||
var changeRead = change.indexOf('r') != -1;
|
||||
var changeWrite = change.indexOf('w') != -1;
|
||||
var changeExec = change.indexOf('x') != -1;
|
||||
var changeExecDir = change.indexOf('X') != -1;
|
||||
var changeSticky = change.indexOf('t') != -1;
|
||||
var changeSetuid = change.indexOf('s') != -1;
|
||||
|
||||
if (changeExecDir && isDir)
|
||||
changeExec = true;
|
||||
|
||||
var mask = 0;
|
||||
if (changeOwner) {
|
||||
|
|
|
@ -125,6 +125,17 @@ 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');
|
||||
|
||||
// Support capital X ("entry" permission aka directory-only execute)
|
||||
|
||||
shell.chmod('744', 'resources/chmod/xdir');
|
||||
shell.chmod('644', 'resources/chmod/xdir/file');
|
||||
shell.chmod('744', 'resources/chmod/xdir/deep');
|
||||
shell.chmod('644', 'resources/chmod/xdir/deep/file');
|
||||
shell.chmod('-R', 'a+X', 'resources/chmod/xdir');
|
||||
|
||||
assert.equal(fs.statSync('resources/chmod/xdir').mode & parseInt('755', 8), parseInt('755', 8));
|
||||
assert.equal(fs.statSync('resources/chmod/xdir/file').mode & parseInt('644', 8), parseInt('644', 8));
|
||||
assert.equal(fs.statSync('resources/chmod/xdir/deep').mode & parseInt('755', 8), parseInt('755', 8));
|
||||
assert.equal(fs.statSync('resources/chmod/xdir/deep/file').mode & parseInt('644', 8), parseInt('644', 8));
|
||||
|
||||
shell.exit(123);
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
a file
|
|
@ -0,0 +1 @@
|
|||
a file
|
Загрузка…
Ссылка в новой задаче