1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-01 05:16:10 +01:00

Ensure no deprecate exists in slate-core development (#1991)

* Throw error in test mode

* Ensure process

* Allow deprecate with user config

* Style fix

* fix grammer typo
This commit is contained in:
Jinxuan Zhu 2018-07-27 18:01:35 -04:00 committed by Ian Storm Taylor
parent 8deecc4461
commit c64c2ff025
2 changed files with 12 additions and 1 deletions

View File

@ -98,7 +98,7 @@
"release": "yarn build:production && yarn test && yarn lint && lerna publish && yarn gh-pages",
"server": "webpack-dev-server --config ./support/webpack/config.js",
"start": "npm-run-all --parallel --print-label watch server",
"test": "cross-env BABEL_ENV=test mocha --require babel-core/register ./packages/*/test/index.js",
"test": "cross-env BABEL_ENV=test FORBID_DEPRECATIONS=true mocha --require babel-core/register ./packages/*/test/index.js",
"watch": "rollup --config ./support/rollup/config.js --watch"
}
}

View File

@ -1,5 +1,12 @@
/* eslint-disable no-console */
/**
* Is deprecate interface forbidden?
*/
const FORBID_DEPRECATE =
process && process.env && process.env.FORBID_DEPRECATIONS
/**
* Is in development?
*
@ -75,6 +82,10 @@ function warn(message, ...args) {
*/
function deprecate(version, message, ...args) {
if (FORBID_DEPRECATE) {
throw new Error(`Deprecation (${version}): ${message}`)
}
log('warn', `Deprecation (${version}): ${message}`, ...args)
}