1 | 'use strict';
|
2 |
|
3 | const resolveConfig = require('./resolveConfig');
|
4 | const globby = require('globby');
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | module.exports = async function printConfig({
|
13 | cwd = process.cwd(),
|
14 | code,
|
15 | config,
|
16 | configBasedir,
|
17 | configFile,
|
18 | globbyOptions,
|
19 | files,
|
20 | }) {
|
21 | const isCodeNotFile = code !== undefined;
|
22 | const filePath = files && files[0];
|
23 |
|
24 | if (!files || files.length !== 1 || !filePath || isCodeNotFile) {
|
25 | return Promise.reject(
|
26 | new Error('The --print-config option must be used with exactly one file path.'),
|
27 | );
|
28 | }
|
29 |
|
30 | if (globby.hasMagic(filePath)) {
|
31 | return Promise.reject(new Error('The --print-config option does not support globs.'));
|
32 | }
|
33 |
|
34 | return (
|
35 | (await resolveConfig(filePath, {
|
36 | cwd: (globbyOptions && globbyOptions.cwd) || cwd,
|
37 | config,
|
38 | configBasedir,
|
39 | configFile,
|
40 | })) || null
|
41 | );
|
42 | };
|