How to use the chownSync function from graceful-fs

Find comprehensive JavaScript graceful-fs.chownSync code examples handpicked from public code repositorys.

427
428
429
430
431
432
433
434
435
436
437
exports.lchmod = Promise.promisify(fs.lchmod);
exports.lchmodSync = fs.lchmodSync;


// chown
exports.chown = Promise.promisify(fs.chown);
exports.chownSync = fs.chownSync;
exports.fchown = Promise.promisify(fs.fchown);
exports.fchownSync = fs.fchownSync;
exports.lchown = Promise.promisify(fs.lchown);
exports.lchownSync = fs.lchownSync;
fork icon9
star icon48
watch icon0

+ 7 other calls in file

49
50
51
52
53
54
55
56
57
58
59
const isRoot = process.getuid && process.getuid() === 0
const isSudo = isRoot && process.env.SUDO_UID && process.env.SUDO_GID
if (isSudo) {
  const sudoUid = +process.env.SUDO_UID
  const sudoGid = +process.env.SUDO_GID
  fs.chownSync(commonCache, sudoUid, sudoGid)
}


const returnCwd = path.dirname(__dirname)
const find = require('which').sync('find')
fork icon0
star icon0
watch icon0

+ 3 other calls in file

216
217
218
219
220
221
222
223
224
225
  }
  if (options.fsync !== false) {
    fs.fsyncSync(fd)
  }
  fs.closeSync(fd)
  if (options.chown) fs.chownSync(tmpfile, options.chown.uid, options.chown.gid)
  if (options.mode) fs.chmodSync(tmpfile, options.mode)
  fs.renameSync(tmpfile, filename)
  removeOnExitHandler()
} catch (err) {
fork icon0
star icon0
watch icon0

+ 3 other calls in file

114
115
116
117
118
119
120
121
122
123
124
	}
};


exports.chownSync = (path, uid, gid) => {
	try {
		return fs.chownSync(path, uid, gid);
	} catch (error) {
		throw new CpFileError(`chown \`${path}\` failed: ${error.message}`, error);
	}
};
fork icon0
star icon0
watch icon0

15
16
17
18
19
20
21
22
23
24
}

var realChownSync
fs.chownSync = function(path, uid, gid) {
  try {
    fs.chownSync(path, uid, gid);
  } catch (er) {
    if (er) console.trace('chownSync failed', er, path, uid, gid)
    throw er
  }
fork icon0
star icon0
watch icon1

+ 3 other calls in file