printConfig.cjs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. const process = require('node:process');
  5. const globby = require('globby');
  6. const resolveConfig = require('./resolveConfig.cjs');
  7. /** @import {Config as StylelintConfig} from 'stylelint' */
  8. /**
  9. * @param {import('stylelint').LinterOptions} options
  10. * @returns {Promise<StylelintConfig | null>}
  11. */
  12. 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. if (!files || files.length !== 1 || !filePath || isCodeNotFile) {
  24. return Promise.reject(
  25. new Error('The --print-config option must be used with exactly one file path.'),
  26. );
  27. }
  28. if (globby.hasMagic(filePath)) {
  29. return Promise.reject(new Error('The --print-config option does not support globs.'));
  30. }
  31. return (
  32. (await resolveConfig(filePath, {
  33. cwd: (globbyOptions && globbyOptions.cwd) || cwd,
  34. config,
  35. configBasedir,
  36. configFile,
  37. })) || null
  38. );
  39. }
  40. module.exports = printConfig;