Skip to content

Commit

Permalink
Merge pull request #6893 from stylelint/dependabot/npm_and_yarn/cosmi…
Browse files Browse the repository at this point in the history
…config-8.2.0

Bumps [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig) from 8.1.3 to 8.2.0.
- [Changelog](https://github.com/cosmiconfig/cosmiconfig/blob/main/CHANGELOG.md)
- [Commits](cosmiconfig/cosmiconfig@v8.1.3...v8.2.0)

---
updated-dependencies:
- dependency-name: cosmiconfig
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Romain Menke <11521496+romainmenke@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 5, 2023
2 parents f1ace61 + 83a4698 commit f7b660d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/blue-lions-guess.md
@@ -0,0 +1,5 @@
---
"stylelint": patch
---

Fixed: Segmentation fault errors for Cosmiconfig 8.2
8 changes: 7 additions & 1 deletion lib/createStylelint.js
@@ -1,6 +1,6 @@
'use strict';

const { cosmiconfig } = require('cosmiconfig');
const { cosmiconfig, defaultLoadersSync } = require('cosmiconfig');

const augmentConfig = require('./augmentConfig');
const FileCache = require('./utils/FileCache');
Expand All @@ -19,6 +19,12 @@ module.exports = function createStylelint(options = {}) {

_extendExplorer: cosmiconfig('', {
transform: augmentConfig.augmentConfigExtended(cwd),
loaders: {
'.cjs': (cjsPath, cjsContent) =>
Promise.resolve(defaultLoadersSync['.cjs'](cjsPath, cjsContent)),
'.js': (jsPath, cjsContent) =>
Promise.resolve(defaultLoadersSync['.js'](jsPath, cjsContent)),
},
stopDir: STOP_DIR,
}),

Expand Down
7 changes: 6 additions & 1 deletion lib/getConfigForFile.js
Expand Up @@ -3,7 +3,7 @@
const configurationError = require('./utils/configurationError');
const path = require('path');
const { augmentConfigFull } = require('./augmentConfig');
const { cosmiconfig } = require('cosmiconfig');
const { cosmiconfig, defaultLoadersSync } = require('cosmiconfig');

const IS_TEST = process.env.NODE_ENV === 'test';
const STOP_DIR = IS_TEST ? process.cwd() : undefined;
Expand Down Expand Up @@ -49,6 +49,11 @@ module.exports = async function getConfigForFile(

const configExplorer = cosmiconfig('stylelint', {
transform: (cosmiconfigResult) => augmentConfigFull(stylelint, filePath, cosmiconfigResult),
loaders: {
'.cjs': (cjsPath, cjsContent) =>
Promise.resolve(defaultLoadersSync['.cjs'](cjsPath, cjsContent)),
'.js': (jsPath, cjsContent) => Promise.resolve(defaultLoadersSync['.js'](jsPath, cjsContent)),
},
stopDir: STOP_DIR,
});

Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -118,7 +118,7 @@
"@csstools/selector-specificity": "^2.2.0",
"balanced-match": "^2.0.0",
"colord": "^2.9.3",
"cosmiconfig": "^8.1.3",
"cosmiconfig": "^8.2.0",
"css-functions-list": "^3.1.0",
"css-tree": "^2.3.1",
"debug": "^4.3.4",
Expand Down

0 comments on commit f7b660d

Please sign in to comment.