1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | 'use strict';
|
9 |
|
10 | const fs = require('fs-extra');
|
11 | const path = require('path');
|
12 | const packageJson = require('../../../package.json');
|
13 |
|
14 | const PACKAGES_DIR = path.resolve(__dirname, '../..');
|
15 | const packagePaths = fs.readdirSync(PACKAGES_DIR).map(pkg => {
|
16 | const packageJsonPath = path.join(PACKAGES_DIR, pkg, 'package.json');
|
17 | return {
|
18 | basename: pkg,
|
19 | packageJsonPath,
|
20 | packageJson: fs.readJsonSync(packageJsonPath),
|
21 | packagePath: path.join(PACKAGES_DIR, pkg),
|
22 | };
|
23 | });
|
24 |
|
25 | const env = {
|
26 | root: {
|
27 | directory: path.resolve(__dirname, '../../..'),
|
28 | packageJson,
|
29 | },
|
30 | packagesDir: PACKAGES_DIR,
|
31 | packagePaths,
|
32 | };
|
33 |
|
34 | function workspace(fn) {
|
35 | return (...args) => fn(...args, env);
|
36 | }
|
37 |
|
38 | module.exports = {
|
39 | workspace,
|
40 | };
|