1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | 'use strict';
|
17 |
|
18 | function run(argv, options) {
|
19 | const utils = require('./utils');
|
20 |
|
21 | const prettierOpts = argv.slice(2);
|
22 |
|
23 | const isConfigSet = utils.isOptionSet(
|
24 | prettierOpts,
|
25 | '--find-config-path',
|
26 | '--no-config',
|
27 | '--config',
|
28 | );
|
29 | const configFile = isConfigSet ? null : utils.getConfigFile('.prettierrc');
|
30 |
|
31 | const args = ['--config-precedence', 'prefer-file'];
|
32 | if (configFile) {
|
33 | args.push('--config', configFile);
|
34 | }
|
35 | args.push(...prettierOpts);
|
36 |
|
37 | return utils.runCLI('prettier/bin/prettier.cjs', args, options);
|
38 | }
|
39 |
|
40 | module.exports = run;
|
41 | if (require.main === module) run(process.argv);
|