import * as path from 'path' ; import { Import , IPackageJson , PackageJsonLookup } from '@rushstack/node-core-library' ; const RUSH_LIB_NAME = '@microsoft/rush-lib' ; type RushLibModuleType = Record < string , unknown > ; declare const global ; let rushLibModule = global . ___rush___rushLibModule ; if ( rushLibModule === undefined ) { const importingPath = module ?. parent ?. filename ; if ( importingPath !== undefined ) { const callerPackageFolder = PackageJsonLookup . instance . tryGetPackageFolderFor ( importingPath ) ; if ( callerPackageFolder !== undefined ) { const callerPackageJson = require ( path . join ( callerPackageFolder , 'package.json' ) ) ; if ( ( callerPackageJson . dependencies && callerPackageJson . dependencies [ RUSH_LIB_NAME ] !== undefined ) || ( callerPackageJson . devDependencies && callerPackageJson . devDependencies [ RUSH_LIB_NAME ] !== undefined ) || ( callerPackageJson . peerDependencies && callerPackageJson . peerDependencies [ RUSH_LIB_NAME ] !== undefined ) ) { try { const rushLibModulePath = Import . resolveModule ( { modulePath : RUSH_LIB_NAME , baseFolderPath : callerPackageFolder } ) ; rushLibModule = require ( rushLibModulePath ) ; } catch ( error ) { } if ( rushLibModule !== undefined ) { global . ___rush___rushLibModule = rushLibModule ; } } } } } if ( rushLibModule === undefined ) { throw new Error ( 'The "@rushstack/rush-sdk" package context has not been initialized.' ) ; } for ( const property in rushLibModule ) { if ( property !== 'default' && ! exports . hasOwnProperty ( property ) ) { const rushLibModuleForClosure = rushLibModule ; Object . defineProperty ( exports , property , { enumerable : true , get : function ( ) { return rushLibModuleForClosure [ property ] ; } } ) ; } }