{"version":3,"sources":["../src/package/packageIsInstalled.ts"],"names":["packageIsInstalled","packageName","options","location","assignObject","packageRoot","getPackageRootPath","InvalidProjectPathError","installed","pkgJsonFile","path","fs"],"mappings":";;;;AAeA,eAAsBA,CAAmBC,CAAAA,CAAAA,CAAmBC,CAAoD,CAAA,CAC5G,GAAM,CAAC,SAAAC,CAAQ,CAAA,CAAIC,CAAa,CAAA,CAC5B,WAAY,CAAA,KAChB,CAAEF,CAAAA,CAAO,CACHG,CAAAA,CAAAA,CAAcC,GAAmBH,CAAAA,CAAQ,CAC/C,CAAA,GAAG,CAACE,CAAa,CAAA,MAAM,IAAIE,GAAAA,CAC3B,IAAIC,CAAAA,CAAoB,KACxB,CAAA,GAAG,CACC,IAAMC,CAAcC,CAAAA,CAAAA,CAAK,IAAKL,CAAAA,CAAAA,CAAY,eAAeJ,CAAY,CAAA,cAAc,CACnFO,CAAAA,CAAAA,CAAYG,CAAG,CAAA,UAAA,CAAWF,CAAW,EACzC,CAAM,KAAA,EACN,OAAOD,CACX","file":"chunk-KRH4PDHN.mjs","sourcesContent":["import { InvalidProjectPathError } from \"../errors\"\r\nimport { getPackageRootPath } from \"./getPackageRootPath\"\r\nimport path from \"node:path\"\r\nimport fs from \"node:fs\"\r\nimport { assignObject } from '../object/assignObject'; \r\n\r\n\r\nexport interface PackageIsInstalledOptions{\r\n    location?:string            // 指定一个位置，未指定则使用当前项目的位置\r\n}\r\n\r\n/**\r\n * 查询指定的包是否安装，如果安装则返回版本号\r\n * @param packageName\r\n */\r\nexport async function packageIsInstalled(packageName:string,options?:PackageIsInstalledOptions):Promise<boolean>{\r\n    const {location} = assignObject({\r\n        checkGlobal:false\r\n    },options)\r\n    const packageRoot = getPackageRootPath(location)\r\n    if(!packageRoot) throw new InvalidProjectPathError()\r\n    let installed:boolean = false \r\n    try{\r\n        const pkgJsonFile = path.join(packageRoot,\"node_modules\",packageName,\"package.json\")        \r\n        installed = fs.existsSync(pkgJsonFile)\r\n    }catch{}\r\n    return installed\r\n}"]}