Make api require-able, expose plugin utils (#445)

pull/447/head
cgewecke 5 years ago committed by GitHub
parent f87c274c2f
commit 3612a815e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      api.js
  2. 10
      lib/api.js
  3. 1
      plugins/resources/plugin.utils.js
  4. 14
      test/units/api.js

@ -0,0 +1,4 @@
// For require('solidity-coverage/api');
const api = require('./lib/api');
module.exports = api;

@ -3,7 +3,6 @@ const pify = require('pify');
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const istanbul = require('istanbul'); const istanbul = require('istanbul');
const util = require('util');
const assert = require('assert'); const assert = require('assert');
const detect = require('detect-port'); const detect = require('detect-port');
const _ = require('lodash/lang'); const _ = require('lodash/lang');
@ -13,6 +12,8 @@ const Instrumenter = require('./instrumenter');
const Coverage = require('./coverage'); const Coverage = require('./coverage');
const DataCollector = require('./collector'); const DataCollector = require('./collector');
const AppUI = require('./ui').AppUI; const AppUI = require('./ui').AppUI;
const utils = require('./../plugins/resources/plugin.utils');
/** /**
* Coverage Runner * Coverage Runner
@ -60,6 +61,7 @@ class API {
this.setLoggingLevel(config.silent); this.setLoggingLevel(config.silent);
this.ui = new AppUI(this.log); this.ui = new AppUI(this.log);
this.utils = utils;
} }
/** /**
@ -175,9 +177,11 @@ class API {
/** /**
* Generate coverage / write coverage report / run istanbul * Generate coverage / write coverage report / run istanbul
*/ */
async report() { async report(_folder) {
const folder = _folder || this.istanbulFolder;
const collector = new istanbul.Collector(); const collector = new istanbul.Collector();
const reporter = new istanbul.Reporter(false, this.istanbulFolder); const reporter = new istanbul.Reporter(false, folder);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
try { try {

@ -267,7 +267,6 @@ module.exports = {
loadSolcoverJS: loadSolcoverJS, loadSolcoverJS: loadSolcoverJS,
reportSkipped: reportSkipped, reportSkipped: reportSkipped,
save: save, save: save,
checkContext: checkContext,
toRelativePath: toRelativePath, toRelativePath: toRelativePath,
setupTempFolders: setupTempFolders setupTempFolders: setupTempFolders
} }

@ -1,6 +1,6 @@
const assert = require('assert'); const assert = require('assert');
const util = require('./../util/util.js'); const util = require('./../util/util.js');
const API = require('./../../lib/api.js'); const API = require('./../../api.js');
const detect = require('detect-port'); const detect = require('detect-port');
const Ganache = require('ganache-cli'); const Ganache = require('ganache-cli');
@ -85,4 +85,16 @@ describe('api', () => {
assert(freePort === port); assert(freePort === port);
}) })
it('api.utils', async function(){
const api = new API(opts);
assert(api.utils.assembleFiles !== undefined)
assert(api.utils.checkContext !== undefined)
assert(api.utils.finish !== undefined)
assert(api.utils.getTempLocations !== undefined)
assert(api.utils.setupTempFolders !== undefined)
assert(api.utils.loadSource !== undefined)
assert(api.utils.loadSolcoverJS !== undefined)
assert(api.utils.save !== undefined)
});
}) })

Loading…
Cancel
Save