UNPKG

490 BJavaScriptView Raw
1const fs = require('fs')
2const path = require('path')
3
4exports.identity = function(_) {
5 return _
6}
7
8exports.isMonorepo =
9 fs.existsSync(path.resolve('lerna.json')) ||
10 !!require(path.resolve('package.json')).workspaces
11
12const pkgs = path.resolve('packages')
13
14exports.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