(ctx: Context)
| 10 | |
| 11 | // Iterate through all packages in directory and return a list of changed packages |
| 12 | const getChanged = async (ctx: Context) => { |
| 13 | const changedList: ChangedList = []; |
| 14 | const queue = new PQueue({ concurrency: 4 }); |
| 15 | |
| 16 | const handleHash = async (packagePath: string, packageJson: PackageJson) => { |
| 17 | // Get hash of current package and compare with old hash |
| 18 | const hash = await getHash(packagePath); |
| 19 | if (packageJson.publishHash !== hash || ctx.force) { |
| 20 | changedList.push({ |
| 21 | name: packageJson.name, |
| 22 | hash, |
| 23 | path: packagePath, |
| 24 | version: packageJson.version, |
| 25 | }); |
| 26 | } |
| 27 | }; |
| 28 | |
| 29 | for (const packageDir of ctx.packages) { |
| 30 | const packages = await getPackages(packageDir); |
| 31 | for (const packageName of packages) { |
| 32 | const packagePath = path.join(packageDir, packageName); |
| 33 | |
| 34 | // Check if package.json exists |
| 35 | const packageJson: PackageJson = await fs.readJson( |
| 36 | path.join(process.cwd(), packagePath, 'package.json'), |
| 37 | ); |
| 38 | |
| 39 | void queue.add(() => handleHash(packagePath, packageJson)); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | await queue.onIdle(); |
| 44 | return changedList; |
| 45 | }; |
| 46 | |
| 47 | const changed = async (options: ChangedFlags) => { |
| 48 | consola.info(colors.bold(colors.blue('Checking packages...'))); |
no test coverage detected