license import * as path from 'path' ; /**
 * Resolves a given path through Bazel while respecting the specified parent directory.
 * Usually `require.resolve` could just be used for resolving runfiles relatively, but support
 * for this has been removed and absolute manifest paths or the runfile helpers are now needed
 * on Windows. This helper provides a resolution method that works the same on all platforms.
 */ export function resolveBazelPath ( parent , relativePath ) { if ( process . env [ 'RUNFILES_MANIFEST_ONLY' ] !== '1' ) { return path . join ( parent , relativePath ) ; } const { runfiles } = require ( '@bazel/runfiles' ) ; const projectDirs = [ path . join ( runfiles . resolve ( 'npm/node_modules' ) , runfiles . workspace ) , runfiles . resolve ( runfiles . workspace ) , ] ; for ( const projectDir of projectDirs ) { const relativeParent = path . relative ( projectDir , parent ) ; const workspacePath = path . join ( relativeParent , relativePath ) . replace ( /\\/g , '/' ) ; try { const result = runfiles . resolveWorkspaceRelative ( workspacePath ) ; if ( result ) { return result ; } } catch { } } throw Error ( `Could not resolve path. Looked in: ${ projectDirs . join ( ', ' ) }` ) ; }