Comparing version 3.0.0 to 4.0.0
/** | ||
Check if the process is running as Administrator on Windows. | ||
Check if the process is running as administrator on Windows. | ||
@returns Whether the process is running as Administrator. | ||
@returns Whether the process is running as administrator. | ||
@example | ||
``` | ||
import isAdmin = require('is-admin'); | ||
import isAdmin from 'is-admin'; | ||
(async () => { | ||
console.log(await isAdmin()); | ||
//=> false | ||
})(); | ||
console.log(await isAdmin()); | ||
//=> false | ||
``` | ||
*/ | ||
declare function isAdmin(): Promise<boolean>; | ||
export = isAdmin; | ||
export default function isAdmin(): Promise<boolean>; |
13
index.js
@@ -1,3 +0,3 @@ | ||
'use strict'; | ||
const execa = require('execa'); | ||
import process from 'node:process'; | ||
import execa from 'execa'; | ||
@@ -9,3 +9,3 @@ // https://stackoverflow.com/a/28268802 | ||
return true; | ||
} catch (_) { | ||
} catch { | ||
return false; | ||
@@ -15,3 +15,3 @@ } | ||
module.exports = async () => { | ||
export default async function isAdmin() { | ||
if (process.platform !== 'win32') { | ||
@@ -22,5 +22,4 @@ return false; | ||
try { | ||
// TODO: Convert this to not use `.shell` as it's slighly faster | ||
// https://stackoverflow.com/a/21295806/1641422 | ||
await execa.shell('fsutil dirty query %systemdrive%'); | ||
await execa('fsutil', ['dirty', 'query', process.env.systemdrive]); | ||
return true; | ||
@@ -34,2 +33,2 @@ } catch (error) { | ||
} | ||
}; | ||
} |
{ | ||
"name": "is-admin", | ||
"version": "3.0.0", | ||
"description": "Check if the process is running as Administrator on Windows", | ||
"version": "4.0.0", | ||
"description": "Check if the process is running as administrator on Windows", | ||
"license": "MIT", | ||
"repository": "sindresorhus/is-admin", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0" | ||
}, | ||
@@ -38,9 +41,9 @@ "scripts": { | ||
"dependencies": { | ||
"execa": "^1.0.0" | ||
"execa": "^5.1.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.17.0", | ||
"xo": "^0.44.0" | ||
} | ||
} |
# is-admin | ||
> Check if the process is running as Administrator on Windows | ||
> Check if the process is running as administrator on Windows | ||
## Install | ||
@@ -12,15 +11,11 @@ | ||
## Usage | ||
```js | ||
const isAdmin = require('is-admin'); | ||
import isAdmin from 'is-admin'; | ||
(async () => { | ||
console.log(await isAdmin()); | ||
//=> false | ||
})(); | ||
console.log(await isAdmin()); | ||
//=> false | ||
``` | ||
## API | ||
@@ -30,12 +25,6 @@ | ||
Returns a `Promise<boolean>` indicating whether the process is running as Administrator. | ||
Returns a `Promise<boolean>` indicating whether the process is running as administrator. | ||
## Related | ||
- [is-elevated](https://github.com/sindresorhus/is-elevated) - Check if the process is running with elevated privileges *(cross-platform)* | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
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
Yes
3281
37
29
2
+ Addedcross-spawn@7.0.5(transitive)
+ Addedexeca@5.1.1(transitive)
+ Addedget-stream@6.0.1(transitive)
+ Addedhuman-signals@2.1.0(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addednpm-run-path@4.0.1(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedstrip-final-newline@2.0.0(transitive)
+ Addedwhich@2.0.2(transitive)
- Removedcross-spawn@6.0.5(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedexeca@1.0.0(transitive)
- Removedget-stream@4.1.0(transitive)
- Removedis-stream@1.1.0(transitive)
- Removednice-try@1.0.5(transitive)
- Removednpm-run-path@2.0.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedpump@3.0.2(transitive)
- Removedsemver@5.7.2(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedexeca@^5.1.1