@@ -7,24 +7,30 @@ import open from 'open';
7
7
import { existsSync } from 'fs' ;
8
8
import { join , dirname } from 'path' ;
9
9
import { fileURLToPath } from 'url' ;
10
+ import { createRequire } from 'module' ;
11
+ const require = createRequire ( import . meta. url ) ;
12
+ const gitCommitInfo = require ( 'git-commit-info' ) ;
13
+
10
14
11
15
if ( ! existsSync ( "./dist" ) ) await import ( "./esbuild.prod.js" ) ;
12
16
13
17
const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
14
18
15
19
const port = process . env . PORT || 3000 ;
16
20
const _v = process . env . npm_package_version ;
21
+ const info = {
22
+ hashShort : `${ JSON . stringify ( gitCommitInfo ( ) . shortHash ) . replace ( '"' , "" ) . replace ( "/" , "" ) . replace ( '\"' , "" ) } ` ,
23
+ hash : `${ JSON . stringify ( gitCommitInfo ( ) . hash ) . replace ( '"' , "" ) . replace ( "/" , "" ) . replace ( '\"' , "" ) } ` ,
24
+ version : _v ,
25
+ }
17
26
18
27
const bare = createBareServer ( '/bare/' ) ;
19
28
const serverFactory = ( handler , opts ) => {
20
29
return createServer ( )
21
30
. on ( "request" , ( req , res ) => {
22
- if ( req . url === "/version" ) {
23
- const versionResponse = {
24
- version : _v ,
25
- } ;
31
+ if ( req . url === "/info" ) {
26
32
res . writeHead ( 200 , { 'Content-Type' : 'application/json' } ) ;
27
- res . end ( JSON . stringify ( versionResponse ) ) ;
33
+ res . end ( JSON . stringify ( info ) ) ;
28
34
} else if ( bare . shouldRoute ( req ) ) {
29
35
bare . routeRequest ( req , res ) ;
30
36
} else {
0 commit comments