import * as fs from 'fs' ; import { getPackageJsonPath } from '../util/packageInfo' ; /**
 * Returns true if Redspot is installed locally or linked from its repository,
 * by looking for it using the node module resolution logic.
 *
 * If a config file is provided, we start looking for it from it. Otherwise,
 * we use the current working directory.
 */ export function isRedspotInstalledLocallyOrLinked ( configPath ? ) { try { const resolvedPackageJson = require . resolve ( 'redspot/package.json' , { paths : [ configPath ?? process . cwd ( ) ] } ) ; const thisPackageJson = getPackageJsonPath ( ) ; return ( fs . realpathSync ( resolvedPackageJson ) === fs . realpathSync ( thisPackageJson ) || thisPackageJson . includes ( 'redspot/packages/redspot-core/package.json' ) ) ; } catch ( _ ) { return false ; } } /**
 * Checks whether we're using Redspot in development mode (that is, we're working _on_ Redspot).
 */ export function isLocalDev ( ) { return isRunningRedspotCoreTests ( ) || ! __filename . includes ( 'node_modules' ) ; } export function isRunningRedspotCoreTests ( ) { return __filename . endsWith ( '.ts' ) ; }