fix: add plugin name to deprecation message

This commit is contained in:
thomas williams
2021-01-08 10:40:31 -08:00
parent 23f7c44800
commit 8c73f032fb
2 changed files with 7 additions and 2 deletions
+6 -2
View File
@@ -28,13 +28,17 @@ function postcss (...plugins) {
postcss.plugin = function plugin (name, initializer) {
if (console && console.warn) {
console.warn(
'postcss.plugin was deprecated. Migration guide:\n' +
'in ' +
name +
': postcss.plugin was deprecated. Migration guide:\n' +
'https://evilmartians.com/chronicles/postcss-8-plugin-migration'
)
if (process.env.LANG && process.env.LANG.startsWith('cn')) {
// istanbul ignore next
console.warn(
'postcss.plugin 被弃用. 迁移指南:\n' +
'在 ' +
name +
' 里面 postcss.plugin 被弃用. 迁移指南:\n' +
'https://www.w3ctech.com/topic/2226'
)
}
+1
View File
@@ -51,6 +51,7 @@ it('creates plugin', () => {
}
})
expect(console.warn).toHaveBeenCalledTimes(1)
expect(console.warn).toHaveBeenCalledWith(expect.stringMatching(/test/))
let func1: any = postcss(plugin).plugins[0]
expect(func1.postcssPlugin).toEqual('test')