UNPKG

1.02 kBPlain TextView Raw
1import debugFactory from 'debug';
2import rc from 'rc';
3
4const debug = debugFactory('clark:lib:config');
5
6/**
7 * Root of the config object
8 */
9export interface Config {
10 scripts?: ScriptConfig;
11 /**
12 * Glob or array of globs indicating the directories that contain the
13 * monorepo's `package.json`s
14 */
15 include?: string | string[];
16}
17
18/**
19 * Scripts section of the config object
20 */
21export interface ScriptConfig {
22 [key: string]: string;
23}
24
25/**
26 * Loads the .clarkrc config file for this project
27 */
28export function load(): Config {
29 debug('Looking for .clarkrc files');
30 const conf = rc('clark', {
31 // `packages/node_modules/*/package.json` and
32 // `packages/node_modules/@*/*/package.json` are the only valid package
33 // locations in an alle-style monorep
34 include: 'packages/node_modules/{*,@*/*}',
35 });
36 if (conf.configs && conf.configs.length) {
37 debug(`Found "${conf.configs.length}" .clarkrc files`);
38 return conf;
39 }
40 debug('Did not find any .clarkrc files');
41 return {};
42}