1 | const fs = require('fs')
|
2 | const path = require('path')
|
3 |
|
4 | exports.identity = function(_) {
|
5 | return _
|
6 | }
|
7 |
|
8 | exports.isMonorepo =
|
9 | fs.existsSync(path.resolve('lerna.json')) ||
|
10 | !!require(path.resolve('package.json')).workspaces
|
11 |
|
12 | const pkgs = path.resolve('packages')
|
13 |
|
14 | exports.allowModules = exports.isMonorepo
|
15 | ? fs.existsSync(pkgs) &&
|
16 | fs.statSync(pkgs).isDirectory() &&
|
17 | fs
|
18 | .readdirSync(pkgs)
|
19 | .map(pkg => require(path.resolve(pkgs, pkg, 'package.json')).name)
|
20 | : undefined
|