native-is-elevated
Advanced tools
Comparing version 0.1.0 to 0.1.1
12
index.js
'use strict'; | ||
var isElevatedModule = null; | ||
var isElevated = null; | ||
var tried = false; | ||
@@ -9,3 +9,3 @@ | ||
try { | ||
isElevatedModule = require('./build/Release/is-elevated'); | ||
isElevated = require('./build/Release/is-elevated'); | ||
} catch (err) { | ||
@@ -16,9 +16,9 @@ console.error(err); | ||
if (!isElevatedModule) { | ||
if (!isElevated) { | ||
return false; | ||
} | ||
var r = false; | ||
var retValue = false; | ||
try { | ||
r = isElevatedModule.isElevated(); | ||
retValue = isElevated.isElevated(); | ||
} catch (err) { | ||
@@ -28,3 +28,3 @@ console.error(err); | ||
return r; | ||
return retValue; | ||
}; |
{ | ||
"name": "native-is-elevated", | ||
"version": "0.1.0", | ||
"description": "Native Node module for checking if the process is being run with elevated privileges", | ||
"version": "0.1.1", | ||
"description": "Native module for checking if the process is being run with elevated privileges", | ||
"main": "index.js", | ||
"scripts": { | ||
"configure": "node-gyp configure", | ||
"build": "node-gyp build", | ||
@@ -8,0 +9,0 @@ "test": "ava" |
14
test.js
var test = require('ava').serial; | ||
var isElevated = require('.'); | ||
// Note that 1 of the 2 tests will fail depending on if you're running | ||
// it normally, or with root/admin rights | ||
test('normal', t => { | ||
t.false(isElevated()); | ||
t.false(isElevated()); | ||
}); | ||
test('elevated', t => { | ||
if (process.platform === 'win32') { | ||
// TODO | ||
} else { | ||
const _ = process.getuid; | ||
process.getuid = () => 0; | ||
t.true(isElevated()); | ||
process.getuid = _; | ||
} | ||
t.true(isElevated()); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4359
33