From 94d342ce63e3de8a27931345a4d1a6de50e2f22c Mon Sep 17 00:00:00 2001 From: Manuel Wiedenmann Date: Wed, 24 Apr 2019 19:31:26 +0200 Subject: [PATCH] Replace console.log by deprecate function --- lib/kredits.js | 8 ++++---- lib/utils/deprecate.js | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 lib/utils/deprecate.js diff --git a/lib/kredits.js b/lib/kredits.js index babbc6a..d477274 100644 --- a/lib/kredits.js +++ b/lib/kredits.js @@ -1,6 +1,7 @@ const ethers = require('ethers'); const Preflight = require('./utils/preflight'); +const deprecate = require('./utils/deprecate'); const ABIS = { Contributor: require('./abis/Contributor.json'), @@ -50,19 +51,18 @@ class Kredits { return this.Kernel.getApp(contractName).then((address) => { this.addresses[contractName] = address; }).catch((error) => { - console.log(error); throw new Error(`Failed to get address for ${contractName} from DAO at ${this.Kernel.contract.address} - ${error.message}` ); }); }); - return Promise.all(addressPromises).then(() => { return this }); + return Promise.all(addressPromises).then(() => { return this; }); }); } static setup (provider, signer, ipfsConfig = null) { - console.log('Kredits.setup() is deprecated use new Kredits().init() instead'); + deprecate('Kredits.setup() is deprecated use new Kredits().init() instead'); return new Kredits(provider, signer, { ipfsConfig: ipfsConfig }).init(); } @@ -80,7 +80,7 @@ class Kredits { } get Contributors () { - console.log('Contributors is deprecated use Contributor instead'); + deprecate('Contributors is deprecated use Contributor instead'); return this.Contributor; } diff --git a/lib/utils/deprecate.js b/lib/utils/deprecate.js new file mode 100644 index 0000000..bca6e8c --- /dev/null +++ b/lib/utils/deprecate.js @@ -0,0 +1,5 @@ +/*eslint no-console: ["error", { allow: ["warn"] }] */ + +module.exports = function deprecate (msg) { + console.warn(msg); +};