File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 1+ <a name =" 1.0.1 " ></a >
2+ # [ 1.0.1] ( https://github.com/faker-javascript/lastname ) (2022-01-18)
3+ * Fix issue with file path.
4+
15<a name =" 1.0.0 " ></a >
26# [ 1.0.0] ( https://github.com/faker-javascript/lastname ) (2022-01-18)
37* Initial release
Original file line number Diff line number Diff line change 1+ import path from 'node:path' ;
12import { loadJsonFileSync } from 'load-json-file' ;
23
34export default function lastName ( options ) {
45 options = options || { } ;
56 const locale = options . locale === undefined ? 'en_US' : options . locale ;
6- const lastnames = loadJsonFileSync ( `./locales/${ locale } /lastnames.json` ) ;
7+ const filePath = `./locales/${ locale } /lastnames.json` ;
8+ let lastnames = [ ] ;
9+
10+ try {
11+ lastnames = loadJsonFileSync ( filePath ) ;
12+ } catch {
13+ lastnames = loadJsonFileSync ( path . resolve ( 'node_modules/@fakerjs/lastname/' , filePath ) ) ;
14+ }
15+
716 return lastnames [ Math . floor ( Math . random ( ) * lastnames . length ) ] ;
817}
Original file line number Diff line number Diff line change 11{
22 "name" : " @fakerjs/lastname" ,
3- "version" : " 1.0.0 " ,
3+ "version" : " 1.0.1 " ,
44 "description" : " Lastname package provides functionality to generate a fake last name value." ,
55 "license" : " MIT" ,
66 "repository" : " faker-javascript/lastname" ,
You can’t perform that action at this time.
0 commit comments