File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,28 @@ const watch = process.argv.includes('--watch');
22const minify = process . argv . includes ( '--minify' ) ;
33const success = watch ? 'Watch build succeeded' : 'Build succeeded' ;
44const fs = require ( 'fs' ) ;
5+ const path = require ( 'path' ) ;
6+
7+ // Replace telemetry token before building
8+ function replaceTelemetryToken ( ) {
9+ const telemetryToken = process . env . TELEMETRY_TRACKING_TOKEN ;
10+ if ( ! telemetryToken ) {
11+ console . error ( 'Error: TELEMETRY_TRACKING_TOKEN environment variable is not set' ) ;
12+ process . exit ( 1 ) ;
13+ }
14+
15+ const constantsPath = path . join ( __dirname , '../src/constants.ts' ) ;
16+ let constantsContent = fs . readFileSync ( constantsPath , 'utf8' ) ;
17+
18+ // Replace the placeholder with the actual token
19+ constantsContent = constantsContent . replace ( '<TELEMETRY_TRACKING_TOKEN>' , telemetryToken ) ;
20+
21+ fs . writeFileSync ( constantsPath , constantsContent ) ;
22+ console . log ( 'Telemetry token replaced successfully' ) ;
23+ }
24+
25+ // Replace the token before building
26+ replaceTelemetryToken ( ) ;
527
628require ( 'esbuild' )
729 . build ( {
You can’t perform that action at this time.
0 commit comments