Skip to content

Commit

Permalink
Remove process.umask() call from config default
Browse files Browse the repository at this point in the history
Since we now are using pacote/tar in a way that will rely on the default
process umask setting, and we set file/directory modes explicitly
anyway, there's no need to have a default umask setting that calls
process.umask()

As this method is not worker-thread safe, and is deprecated, it's best
for us to stop using it.

Fix: #1103
  • Loading branch information
isaacs committed Jan 7, 2021
1 parent f9d3961 commit b3f3987
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 36 deletions.
2 changes: 1 addition & 1 deletion lib/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const defaults = {
'tag-version-prefix': 'v',
timing: false,
tmp: tmpdir(),
umask: process.umask ? process.umask() : 0o22,
umask: 0,
unicode,
'update-notifier': true,
usage: false,
Expand Down
6 changes: 3 additions & 3 deletions tap-snapshots/test-lib-utils-config.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Object {
"tag-version-prefix": "v",
"timing": false,
"tmp": "/tmp",
"umask": 18,
"umask": 0,
"unicode": true,
"update-notifier": true,
"usage": false,
Expand Down Expand Up @@ -658,7 +658,7 @@ Object {
"tag-version-prefix": "v",
"timing": false,
"tmp": "/tmp",
"umask": 22,
"umask": 0,
"unicode": true,
"update-notifier": true,
"usage": false,
Expand Down Expand Up @@ -1185,7 +1185,7 @@ Object {
"tag-version-prefix": "v",
"timing": false,
"tmp": "/tmp",
"umask": 22,
"umask": 0,
"unicode": true,
"update-notifier": true,
"usage": false,
Expand Down
32 changes: 0 additions & 32 deletions test/lib/utils/config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
const t = require('tap')
const requireInject = require('require-inject')
Object.defineProperty(process, 'umask', {
value: () => 0o26,
writable: true,
configurable: true,
enumerable: true,
})

// have to fake the node version, or else it'll only pass on this one
Object.defineProperty(process, 'version', {
Expand Down Expand Up @@ -93,32 +87,6 @@ t.test('no working network interfaces, on windows', t => {
t.end()
})

t.test('no process.umask() method', t => {
Object.defineProperty(process, 'umask', {
value: null,
writable: true,
configurable: true,
enumerable: true,
})
t.teardown(() => {
Object.defineProperty(process, 'umask', {
value: () => 0o26,
writable: true,
configurable: true,
enumerable: true,
})
})
const config = requireInject('../../../lib/utils/config.js', {
os: { tmpdir, networkInterfaces: networkInterfacesThrow },
'@npmcli/ci-detect': () => false,
'../../../lib/utils/is-windows.js': true,
'../../../package.json': pkg,
})
t.equal(config.defaults.umask, 0o22)
t.matchSnapshot(config)
t.end()
})

t.test('no comspec on windows', t => {
delete process.env.ComSpec
const config = requireInject('../../../lib/utils/config.js', {
Expand Down

0 comments on commit b3f3987

Please sign in to comment.