@@ -9,7 +9,8 @@ const https = require("https");
99const crypto = require ( "crypto" ) ;
1010const net = require ( 'net' ) ;
1111
12- const { isEnvTrue, EDGE_PORT , PROTOCOL , configureEnvironment } = require ( "../src" ) ;
12+ const { isEnvTrue, EDGE_PORT , PROTOCOL , configureEnvironment } = require ( path . resolve ( __dirname , ".." , "src" ) ) ;
13+ const pkg = require ( path . resolve ( __dirname , ".." , "package.json" ) ) ;
1314
1415// constants and custom config values
1516
@@ -22,6 +23,17 @@ const AWS_ENVAR_ALLOWLIST = process.env.AWS_ENVAR_ALLOWLIST || "";
2223// UTIL FUNCTIONS
2324//----------------
2425
26+ function printVersion ( ) {
27+ try {
28+ const lib = require ( "aws-cdk/lib" ) ;
29+ const cdkVersion = require ( path . join ( lib . rootDir ( ) , 'package.json' ) ) . version . replace ( / \+ [ 0 - 9 a - f ] + $ / , '' ) ;
30+ console . log ( `cdklocal v${ pkg . version } ` ) ;
31+ console . log ( `cdk cli version v${ cdkVersion } ` ) ;
32+ } catch ( e ) {
33+ console . log ( `cdklocal v${ pkg . version } ` ) ;
34+ }
35+ }
36+
2537const getLocalEndpoint = async ( ) => process . env . AWS_ENDPOINT_URL || `${ PROTOCOL } ://${ await getLocalHost ( ) } ` ;
2638
2739var resolvedHostname = undefined ;
@@ -484,6 +496,12 @@ const patchPost_2_14 = () => {
484496 }
485497} ;
486498
499+ // handle printing version information
500+ if ( process . argv [ 2 ] === "--version" || process . argv [ 2 ] === "-v" ) {
501+ printVersion ( ) ;
502+ process . exit ( 0 ) ;
503+ }
504+
487505if ( isEsbuildBundle ( ) ) {
488506 // load for CDK version 2.14.0 and above
489507 // (v2.14.0+ uses a self-contained bundle, see https://github.com/aws/aws-cdk/pull/18667)
0 commit comments