Skip to content

Commit 220d8d6

Browse files
authored
fix: throw error only when child process exits with error code (giuseppeg#41)
fix giuseppeg#40
1 parent ea48949 commit 220d8d6

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

fixture-postcss-plugin.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const postcss = require('postcss')
2+
3+
module.exports = postcss.plugin('postcss-fixture', () => (root) => {
4+
console.warn('warn')
5+
console.error('error')
6+
return root
7+
})

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { spawnSync } = require('child_process');
2-
const path = require('path');
1+
const { spawnSync } = require('child_process')
2+
const path = require('path')
33

44
module.exports = (css, settings) => {
55
const cssWithPlaceholders = css
@@ -15,7 +15,7 @@ module.exports = (css, settings) => {
1515
encoding: 'utf8'
1616
})
1717

18-
if (result.stderr) {
18+
if (result.status !== 0) {
1919
if (result.stderr.includes('Invalid PostCSS Plugin')) {
2020
console.error('Next.js 9 default postcss support uses a non standard postcss config schema https://err.sh/next.js/postcss-shape, you must use the interoperable object-based format instead https://nextjs.org/docs/advanced-features/customizing-postcss-config')
2121
}

postcss.config.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
const path = require('path')
2+
13
module.exports = {
2-
"plugins": {
3-
"postcss-easy-import": {},
4-
"postcss-preset-env": {
5-
"browsers": ['last 2 versions', 'ie >= 10'],
6-
"features": {
7-
"nesting-rules": true,
8-
"color-mod-function": {
9-
unresolved: 'warn'
10-
}
11-
}
4+
plugins: {
5+
'postcss-easy-import': {},
6+
'postcss-preset-env': {
7+
browsers: ['last 2 versions', 'ie >= 10'],
8+
features: {
9+
'nesting-rules': true,
10+
'color-mod-function': {
11+
unresolved: 'warn',
12+
},
13+
},
1214
},
13-
"postcss-spiffing": {}
14-
}
15-
}
15+
'postcss-spiffing': {},
16+
[path.resolve(__dirname, './fixture-postcss-plugin.js')]: {}
17+
},
18+
}

0 commit comments

Comments
 (0)