Skip to content

Commit

Permalink
Replace fs.accessSync call to fs.statSync
Browse files Browse the repository at this point in the history
fs.accessSync does not exist in Node 0.10.x.
  • Loading branch information
richardlau committed Jun 15, 2016
1 parent d973cf2 commit dbb775c
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions lib/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,45 @@ function configure (gyp, argv, callback) {
'out/Release/node.exp',
'out/Debug/node.exp',
'node.exp']
var found = false
var prefix = 'find exports file'
for (var next = 0; next < candidates.length; next++) {
node_exp_file = path.resolve(node_root_dir, candidates[next])
try {
fs.accessSync(node_exp_file, fs.R_OK)
// exp file found, stop looking
break
var stats = fs.statSync(node_exp_file)
if (stats.uid === process.getuid()) {
if (stats.mode & 0400) {
log.silly(prefix, '%s has owner read permission', node_exp_file)
found = true
break
}
} else if (process.getgroups().some(function (group) {
return stats.gid === group
}, false)) {
if (stats.mode & 0040) {
log.silly(prefix, '%s has group read permission', node_exp_file)
found = true
break
}
} else {
if (stats.mode & 0004) {
log.silly(prefix, '%s has others read permission', node_exp_file)
found = true
break
}
}
log.silly(prefix,
'%s exists but has no read permissions', node_exp_file)
} catch (exception) {
// this candidate was not found or not readable, do nothing
log.silly(prefix, '%s does not exist', node_exp_file)
}
}
if (found) {
log.silly(prefix, 'Found exports file: %s', node_exp_file)
} else {
log.error(prefix, 'Could not find exports file')
}
}

// this logic ported from the old `gyp_addon` python file
Expand Down

0 comments on commit dbb775c

Please sign in to comment.