UNPKG

910 BJavaScriptView Raw
1/**
2 * Copyright IBM Corp. 2019, 2019
3 *
4 * This source code is licensed under the Apache-2.0 license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8'use strict';
9
10const fs = require('fs-extra');
11const path = require('path');
12const packageJson = require('../../../package.json');
13
14const PACKAGES_DIR = path.resolve(__dirname, '../..');
15const 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
25const env = {
26 root: {
27 directory: path.resolve(__dirname, '../../..'),
28 packageJson,
29 },
30 packagesDir: PACKAGES_DIR,
31 packagePaths,
32};
33
34function workspace(fn) {
35 return (...args) => fn(...args, env);
36}
37
38module.exports = {
39 workspace,
40};