chownr icon indicating copy to clipboard operation
chownr copied to clipboard

chownr was not throwing an error when PATH doesn't exist

Open belsholff opened this issue 4 years ago • 1 comments

I found which seems an error not thrown when I try to change ownership of a folder that doesn't exist, in opposition to the behaviour found in fs.chown and in Linux terminal. Look:

chown nobody /folder/not/exist
#chown: can't access '/folder/not/exist': File or directory not found
echo $?
#1
require("fs").chown('/folder/not/exist', process.getuid(), process.getgid(), err => {
    console.error(err);
});
// { [Error: ENOENT: no such file or directory, chown '/folder/not/exist']
//   errno: -2,
//   code: 'ENOENT',
//   syscall: 'chown',
//   path: '/folder/not/exist' }


require('chownr')('/folder/not/exist', process.getuid(), process.getgid(), err => {
    console.error(err);
});
//undefined

Okay, It's easy to workaround, but maybe, embed this can be an improvement.

belsholff avatar Apr 03 '20 22:04 belsholff

patch welcome

isaacs avatar Feb 27 '22 07:02 isaacs