1'use strict'; 2 3// This tests that the lower bits of mode > 0o777 still works in fs.mkdir(). 4 5const common = require('../common'); 6const assert = require('assert'); 7const path = require('path'); 8const fs = require('fs'); 9 10if (common.isWindows) { 11 common.skip('mode is not supported in mkdir on Windows'); 12 return; 13} 14 15const mode = 0o644; 16const maskToIgnore = 0o10000; 17 18const tmpdir = require('../common/tmpdir'); 19tmpdir.refresh(); 20 21function test(mode, asString) { 22 const suffix = asString ? 'str' : 'num'; 23 const input = asString ? 24 (mode | maskToIgnore).toString(8) : (mode | maskToIgnore); 25 26 { 27 const dir = path.join(tmpdir.path, `mkdirSync-${suffix}`); 28 fs.mkdirSync(dir, input); 29 assert.strictEqual(fs.statSync(dir).mode & 0o777, mode); 30 } 31 32 { 33 const dir = path.join(tmpdir.path, `mkdir-${suffix}`); 34 fs.mkdir(dir, input, common.mustSucceed(() => { 35 assert.strictEqual(fs.statSync(dir).mode & 0o777, mode); 36 })); 37 } 38} 39 40test(mode, true); 41test(mode, false); 42