2020-10-27 11:27:17 +01:00
|
|
|
'use strict';
|
|
|
|
|
2020-04-14 19:10:36 +02:00
|
|
|
const { join } = require('path');
|
2020-10-27 11:27:17 +01:00
|
|
|
const { promisify } = require('util');
|
2020-04-14 19:10:36 +02:00
|
|
|
const execa = require('execa');
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
const glob = promisify(require('glob').glob);
|
|
|
|
|
|
|
|
async function run() {
|
2021-04-29 11:11:46 +02:00
|
|
|
const packageDirs = await glob('packages/**/*', { ignore: '**/node_modules/**' });
|
2020-04-14 19:10:36 +02:00
|
|
|
|
|
|
|
console.log('Unlinking all packages');
|
|
|
|
|
2021-04-29 11:11:46 +02:00
|
|
|
const packages = packageDirs
|
2022-08-08 23:33:39 +02:00
|
|
|
.filter((dir) => fs.pathExistsSync(join(dir, 'package.json')))
|
|
|
|
.map((dir) => ({
|
2021-04-29 11:11:46 +02:00
|
|
|
dir,
|
|
|
|
pkgJSON: fs.readJSONSync(join(dir, 'package.json')),
|
|
|
|
}));
|
2020-04-14 19:10:36 +02:00
|
|
|
|
|
|
|
await Promise.all(packages.map(({ dir }) => execa('yarn', ['unlink'], { cwd: dir })));
|
|
|
|
|
2022-08-08 23:33:39 +02:00
|
|
|
const packageNames = packages.map((p) => p.pkgJSON.name).join(' ');
|
2020-04-14 19:10:36 +02:00
|
|
|
console.log(`Package names: \n ${packageNames}\n`);
|
|
|
|
}
|
|
|
|
|
2022-08-08 23:33:39 +02:00
|
|
|
run().catch((err) => console.error(err));
|