File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed
Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @o2s/telemetry ' : patch
3+ ---
4+
5+ added a failsafe around ` configstore ` not being available e.g. in serverless environements
Original file line number Diff line number Diff line change @@ -3,14 +3,20 @@ import { v4 as uuid } from 'uuid';
33
44import { getMetadata } from './metadata' ;
55
6- const config = new Configstore (
7- `o2s` ,
8- {
9- metadata : getMetadata ( ) ,
10- machineId : uuid ( ) ,
11- } ,
12- { globalConfigPath : true } ,
13- ) ;
6+ const data = {
7+ metadata : getMetadata ( ) ,
8+ machineId : uuid ( ) ,
9+ } ;
10+
11+ let config : Pick < Configstore , 'get' > ;
12+
13+ try {
14+ config = new Configstore ( `o2s` , data , { globalConfigPath : true } ) ;
15+ } catch ( _error ) {
16+ config = {
17+ get : ( key : string ) => data [ key as keyof typeof data ] ,
18+ } ;
19+ }
1420
1521const metadata = ( config . get ( 'metadata' ) as ReturnType < typeof getMetadata > ) || getMetadata ( ) ;
1622const machineId = ( config . get ( 'machineId' ) as string ) || uuid ( ) ;
You can’t perform that action at this time.
0 commit comments