File: fix-for-cosmiconfig-7.patch

package info (click to toggle)
node-postcss-load-config 2.1.2%2B~cs6.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 852 kB
  • sloc: javascript: 2,229; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,279 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Description: fix for cosmiconfig ≥ 7
Author: Yadd <yadd@debian.org>
Forwarded: no
Last-Update: 2021-12-30

--- a/src/index.js
+++ b/src/index.js
@@ -2,7 +2,7 @@
 
 const resolve = require('path').resolve
 
-const config = require('cosmiconfig')
+const {cosmiconfig, cosmiconfigSync} = require('cosmiconfig')
 
 const loadOptions = require('./options.js')
 const loadPlugins = require('./plugins.js')
@@ -84,7 +84,7 @@
    */
   path = path ? resolve(path) : process.cwd()
 
-  return config('postcss', options)
+  return cosmiconfig('postcss', options)
     .search(path)
     .then((result) => {
       if (!result) {
@@ -106,7 +106,7 @@
    */
   path = path ? resolve(path) : process.cwd()
 
-  const result = config('postcss', options).searchSync(path)
+  const result = cosmiconfigSync('postcss', options).search(path)
 
   if (!result) {
     throw new Error(`No PostCSS Config found in: ${path}`)
--- a/test/js.test.js
+++ b/test/js.test.js
@@ -84,7 +84,7 @@
     expect(config.options.to).toEqual('./test/js/array/expect/index.css')
 
     expect(config.plugins.length).toEqual(2)
-    expect(typeof config.plugins[0]).toBe('function')
+    expect(typeof config.plugins[0]).toBe('object')
     expect(typeof config.plugins[1]).toBe('object')
 
     expect(config.file)