Replace console.log by deprecate function

This commit is contained in:
fsmanuel 2019-04-24 19:31:26 +02:00
parent f984dec95a
commit 94d342ce63
2 changed files with 9 additions and 4 deletions

View File

@ -1,6 +1,7 @@
const ethers = require('ethers'); const ethers = require('ethers');
const Preflight = require('./utils/preflight'); const Preflight = require('./utils/preflight');
const deprecate = require('./utils/deprecate');
const ABIS = { const ABIS = {
Contributor: require('./abis/Contributor.json'), Contributor: require('./abis/Contributor.json'),
@ -50,19 +51,18 @@ class Kredits {
return this.Kernel.getApp(contractName).then((address) => { return this.Kernel.getApp(contractName).then((address) => {
this.addresses[contractName] = address; this.addresses[contractName] = address;
}).catch((error) => { }).catch((error) => {
console.log(error);
throw new Error(`Failed to get address for ${contractName} from DAO at ${this.Kernel.contract.address} throw new Error(`Failed to get address for ${contractName} from DAO at ${this.Kernel.contract.address}
- ${error.message}` - ${error.message}`
); );
}); });
}); });
return Promise.all(addressPromises).then(() => { return this }); return Promise.all(addressPromises).then(() => { return this; });
}); });
} }
static setup (provider, signer, ipfsConfig = null) { 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(); return new Kredits(provider, signer, { ipfsConfig: ipfsConfig }).init();
} }
@ -80,7 +80,7 @@ class Kredits {
} }
get Contributors () { get Contributors () {
console.log('Contributors is deprecated use Contributor instead'); deprecate('Contributors is deprecated use Contributor instead');
return this.Contributor; return this.Contributor;
} }

5
lib/utils/deprecate.js Normal file
View File

@ -0,0 +1,5 @@
/*eslint no-console: ["error", { allow: ["warn"] }] */
module.exports = function deprecate (msg) {
console.warn(msg);
};