How to use the fchmodSync function from fs

Find comprehensive JavaScript fs.fchmodSync code examples handpicked from public code repositorys.

40
41
42
43
44
45
46
47
48
49
      return false;
    throw e;
  }
};
exports.fchmod = co.promisify(fs.fchmod);
exports.fchmodSync = fs.fchmodSync;
exports.fchown = co.promisify(fs.fchown);
exports.fchownSync = fs.fchownSync;
exports.fdatasync = co.promisify(fs.fdatasync);
exports.fdatasyncSync = fs.fdatasyncSync;
fork icon22
star icon45
watch icon26

105
106
107
108
109
110
111
112
113
114
  assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_async);
} else {
  assert.strictEqual(mode_async, fs.fstatSync(fd).mode & 0o777);
}

fs.fchmodSync(fd, mode_sync);
if (common.isWindows) {
  assert.ok((fs.fstatSync(fd).mode & 0o777) & mode_sync);
} else {
  assert.strictEqual(mode_sync, fs.fstatSync(fd).mode & 0o777);
fork icon16
star icon65
watch icon0

758
759
760
761
762
763
764
765
766
767
768
769


  common.runWithInvalidFD((fd) => {
    fs.fchmod(fd, 0o666, common.mustCall(validateError));


    assert.throws(
      () => fs.fchmodSync(fd, 0o666),
      validateError
    );
  });
}
fork icon42
star icon19
watch icon0

55
56
57
58
59
60
61
62
63
64
{
  const file = path.join(tmpdir.path, `fchmodSync-${suffix}.txt`);
  fs.writeFileSync(file, 'test', 'utf-8');
  const fd = fs.openSync(file, 'w');

  fs.fchmodSync(fd, input);
  assert.strictEqual(fs.fstatSync(fd).mode & 0o777, mode);

  fs.close(fd, assert.ifError);
}
fork icon0
star icon0
watch icon0

+ 4 other calls in file

25
26
27
28
29
30
31
32
33
34
35
    name: 'TypeError',
    message: 'The argument \'mode\' must be a 32-bit unsigned integer or an ' +
             `octal string. Received ${util.inspect(input)}`
  };
  assert.throws(() => fs.fchmod(1, input), errObj);
  assert.throws(() => fs.fchmodSync(1, input), errObj);
});


[-1, 2 ** 32].forEach((input) => {
  const errObj = {
fork icon0
star icon0
watch icon0

+ 7 other calls in file