2020-12-22 17:07:50 +00:00
|
|
|
import path from 'path'
|
|
|
|
import consola from 'consola'
|
|
|
|
import execa from 'execa'
|
|
|
|
import fs from 'fs-extra'
|
|
|
|
import _glob from 'glob'
|
|
|
|
import pify from 'pify'
|
|
|
|
|
|
|
|
const glob = pify(_glob) // TODO: use globby
|
2019-05-28 15:55:54 +00:00
|
|
|
|
2019-07-10 10:45:49 +00:00
|
|
|
async function main () {
|
2019-05-28 15:55:54 +00:00
|
|
|
const packageDirs = await glob('+(packages|distributions)/*')
|
|
|
|
|
|
|
|
const packages = packageDirs.map(pkgDir => ({
|
|
|
|
dir: pkgDir,
|
|
|
|
pkg: fs.readJSONSync(path.join(pkgDir, 'package.json'))
|
|
|
|
}))
|
|
|
|
|
|
|
|
const packageNames = packages.map(p => p.pkg.name).join(' ')
|
|
|
|
|
|
|
|
consola.info(`Linking ${packages.length} packages...`)
|
|
|
|
|
|
|
|
await Promise.all(packages.map(pkg => execa('yarn', ['link'], { cwd: pkg.dir })))
|
|
|
|
|
|
|
|
consola.log(`Link: \nyarn link ${packageNames}\n`)
|
|
|
|
consola.log(`Unlink: \nyarn unlink ${packageNames}\n`)
|
|
|
|
}
|
|
|
|
|
|
|
|
main().catch(consola.error)
|