Comparing version 4.0.1 to 5.0.0
@@ -6,12 +6,8 @@ /** | ||
``` | ||
import fullName = require('fullname'); | ||
import fullName from 'fullname'; | ||
(async () => { | ||
console.log(await fullName()); | ||
//=> 'Sindre Sorhus' | ||
})(); | ||
console.log(await fullName()); | ||
//=> 'Sindre Sorhus' | ||
``` | ||
*/ | ||
declare function fullName(): Promise<string | undefined>; | ||
export = fullName; | ||
export default function fullName(): Promise<string | undefined>; |
45
index.js
@@ -1,7 +0,8 @@ | ||
'use strict'; | ||
const mem = require('mem'); | ||
const execa = require('execa'); | ||
const passwdUser = require('passwd-user'); | ||
const pAny = require('p-any'); | ||
const filterObj = require('filter-obj'); | ||
import process from 'node:process'; | ||
import mem from 'mem'; | ||
import {execa} from 'execa'; | ||
import {passwdUser} from 'passwd-user'; | ||
import pAny from 'p-any'; | ||
import {includeKeys} from 'filter-obj'; | ||
import rc from 'rc'; | ||
@@ -12,3 +13,3 @@ const environmentVariables = [ | ||
'HGUSER', // Mercurial | ||
'C9_USER' // Cloud9 | ||
'C9_USER', // Cloud9 | ||
]; | ||
@@ -30,3 +31,3 @@ | ||
async function checkAuthorName() { | ||
const fullName = require('rc')('npm')['init-author-name']; | ||
const fullName = rc('npm')['init-author-name']; | ||
@@ -51,6 +52,6 @@ if (!fullName) { | ||
async function checkGit() { | ||
const fullName = await execa.stdout('git', [ | ||
const {stdout: fullName} = await execa('git', [ | ||
'config', | ||
'--global', | ||
'user.name' | ||
'user.name', | ||
]); | ||
@@ -66,5 +67,5 @@ | ||
async function checkOsaScript() { | ||
const fullName = await execa.stdout('osascript', [ | ||
const {stdout: fullName} = await execa('osascript', [ | ||
'-e', | ||
'long user name of (system info)' | ||
'long user name of (system info)', | ||
]); | ||
@@ -80,3 +81,3 @@ | ||
async function checkWmic() { | ||
const stdout = await execa.stdout('wmic', [ | ||
const {stdout} = await execa('wmic', [ | ||
'useraccount', | ||
@@ -86,3 +87,3 @@ 'where', | ||
'get', | ||
'fullname' | ||
'fullname', | ||
]); | ||
@@ -100,3 +101,3 @@ | ||
async function checkGetEnt() { | ||
const result = await execa.shell('getent passwd $(whoami)'); | ||
const result = await execa('getent passwd $(whoami)', {shell: true}); | ||
const fullName = (result.stdout.split(':')[4] || '').replace(/,.*/, ''); | ||
@@ -128,18 +129,20 @@ | ||
return await checkEnv(); | ||
} catch (_) {} | ||
} catch {} | ||
try { | ||
return await checkAuthorName(); | ||
} catch (_) {} | ||
} catch {} | ||
try { | ||
return await fallback(); | ||
} catch (_) {} | ||
} catch {} | ||
} | ||
module.exports = mem(getFullName, { | ||
const fullName = mem(getFullName, { | ||
cachePromiseRejection: false, | ||
cacheKey() { | ||
return JSON.stringify(filterObj(process.env, environmentVariables)); | ||
} | ||
return JSON.stringify(includeKeys(process.env, environmentVariables)); | ||
}, | ||
}); | ||
export default fullName; |
{ | ||
"name": "fullname", | ||
"version": "4.0.1", | ||
"version": "5.0.0", | ||
"description": "Get the fullname of the current user", | ||
"license": "MIT", | ||
"repository": "sindresorhus/fullname", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": { | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=18" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
"//test": "xo && ava && tsd", | ||
"test": "xo && tsd" | ||
}, | ||
@@ -37,16 +44,19 @@ "files": [ | ||
"dependencies": { | ||
"execa": "^1.0.0", | ||
"filter-obj": "^2.0.0", | ||
"execa": "^8.0.1", | ||
"filter-obj": "^5.1.0", | ||
"mem": "^5.1.0", | ||
"p-any": "^2.1.0", | ||
"passwd-user": "^3.0.0", | ||
"p-any": "^4.0.0", | ||
"passwd-user": "^4.0.0", | ||
"rc": "^1.2.8" | ||
}, | ||
"devDependencies": { | ||
"ava": "^2.1.0", | ||
"ava": "^5.3.1", | ||
"import-fresh": "^3.0.0", | ||
"mock-require": "^3.0.3", | ||
"tsd": "^0.7.3", | ||
"xo": "^0.24.0" | ||
"tsd": "^0.29.0", | ||
"xo": "^0.56.0" | ||
}, | ||
"ava": { | ||
"serial": true | ||
} | ||
} |
@@ -1,38 +0,28 @@ | ||
# fullname [![Build Status](https://travis-ci.org/sindresorhus/fullname.svg?branch=master)](https://travis-ci.org/sindresorhus/fullname) | ||
# fullname | ||
> Get the full name of the current user | ||
Works on macOS, Linux, and Windows. | ||
## Install | ||
```sh | ||
npm install fullname | ||
``` | ||
$ npm install fullname | ||
``` | ||
Tested on macOS, Linux, and Windows. | ||
## Usage | ||
```js | ||
const fullName = require('fullname'); | ||
import fullName from 'fullname'; | ||
(async () => { | ||
console.log(await fullName()); | ||
//=> 'Sindre Sorhus' | ||
})(); | ||
console.log(await fullName()); | ||
//=> 'Sindre Sorhus' | ||
``` | ||
In the rare case a name can't be found, you could fall back to [`username`](https://github.com/sindresorhus/username). | ||
In the rare case a name cannot be found, you could fall back to [`username`](https://github.com/sindresorhus/username). | ||
## Related | ||
- [fullname-cli](https://github.com/sindresorhus/fullname-cli) - CLI for this module | ||
- [fullname-native](https://github.com/sindresorhus/fullname-native) - Native version of this module | ||
- [fullname-cli](https://github.com/sindresorhus/fullname-cli) - CLI for this package | ||
- [fullname-native](https://github.com/sindresorhus/fullname-native) - Native version of this package | ||
- [username](https://github.com/sindresorhus/username) - Get the username of the current user | ||
## 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
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
5630
Yes
119
29
+ Addedaggregate-error@4.0.1(transitive)
+ Addedclean-stack@4.2.0(transitive)
+ Addedcross-spawn@7.0.3(transitive)
+ Addedescape-string-regexp@5.0.0(transitive)
+ Addedexeca@5.1.18.0.1(transitive)
+ Addedfilter-obj@5.1.0(transitive)
+ Addedget-stream@6.0.18.0.1(transitive)
+ Addedhuman-signals@2.1.05.0.0(transitive)
+ Addedindent-string@5.0.0(transitive)
+ Addedis-stream@2.0.13.0.0(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmimic-fn@4.0.0(transitive)
+ Addednpm-run-path@4.0.15.3.0(transitive)
+ Addedonetime@5.1.26.0.0(transitive)
+ Addedp-any@4.0.0(transitive)
+ Addedp-cancelable@3.0.0(transitive)
+ Addedp-some@6.0.0(transitive)
+ Addedpasswd-user@4.0.0(transitive)
+ Addedpath-key@3.1.14.0.0(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedsignal-exit@4.1.0(transitive)
+ Addedstrip-final-newline@2.0.03.0.0(transitive)
+ Addedwhich@2.0.2(transitive)
- Removedaggregate-error@3.1.0(transitive)
- Removedclean-stack@2.2.0(transitive)
- Removedcross-spawn@6.0.5(transitive)
- Removedend-of-stream@1.4.4(transitive)
- Removedexeca@1.0.0(transitive)
- Removedfilter-obj@2.0.2(transitive)
- Removedget-stream@4.1.0(transitive)
- Removedindent-string@4.0.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-any@2.1.0(transitive)
- Removedp-cancelable@2.1.1(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedp-some@4.1.0(transitive)
- Removedpasswd-user@3.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)
- Removedtype-fest@0.3.1(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedexeca@^8.0.1
Updatedfilter-obj@^5.1.0
Updatedp-any@^4.0.0
Updatedpasswd-user@^4.0.0