forked from strapi/strapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunlink.js
27 lines (20 loc) · 808 Bytes
/
unlink.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
'use strict';
const { join } = require('path');
const { promisify } = require('util');
const execa = require('execa');
const fs = require('fs-extra');
const glob = promisify(require('glob').glob);
async function run() {
const packageDirs = await glob('packages/**/*', { ignore: '**/node_modules/**' });
console.log('Unlinking all packages');
const packages = packageDirs
.filter((dir) => fs.pathExistsSync(join(dir, 'package.json')))
.map((dir) => ({
dir,
pkgJSON: fs.readJSONSync(join(dir, 'package.json')),
}));
await Promise.all(packages.map(({ dir }) => execa('yarn', ['unlink'], { cwd: dir })));
const packageNames = packages.map((p) => p.pkgJSON.name).join(' ');
console.log(`Package names: \n ${packageNames}\n`);
}
run().catch((err) => console.error(err));