Add new parameter for build directory path

pull/272/head
Dimitar Dzhurenov 6 years ago
parent b332c22dc1
commit 72ad835960
  1. 1
      README.md
  2. 11
      lib/app.js

@ -100,6 +100,7 @@ module.exports = {
| copyPackages | *Array* | `[]` | Copies specific `node_modules` packages into the coverage environment. May significantly reduce the time for coverage to complete compared to `copyNodeModules`. Useful if your contracts import solidity files from an npm installed package. |
| skipFiles | *Array* | `['Migrations.sol']` | Array of contracts or folders (with paths expressed relative to the `contracts` directory) that should be skipped when doing instrumentation. `Migrations.sol` is skipped by default, and does not need to be added to this configuration option if it is used. |
| dir | *String* | `.` | Solidity-coverage copies all the assets in your root directory (except `node_modules`) to a special folder where it instruments the contracts and executes the tests. `dir` allows you to define a relative path from the root directory to those assets. Useful if your contracts & tests are within their own folder as part of a larger project.|
| buildDirPath | *String* | `/build/contracts` | Build directory path for compiled smart contracts
### FAQ

@ -43,6 +43,7 @@ class App {
this.skipFiles = config.skipFiles || []; // Which files should be skipped during instrumentation
this.norpc = config.norpc || false; // Launch testrpc-sc internally?
this.port = config.port || 8555; // Port testrpc should listen on
this.buildDirPath = config.buildDirPath || '/build/contracts' // Build directory path for compiled smart contracts
this.copyNodeModules = config.copyNodeModules || false; // Copy node modules into coverageEnv?
this.copyPackages = config.copyPackages || []; // Only copy specific node_modules packages into coverageEnv
@ -115,13 +116,13 @@ class App {
// Compile the contracts before instrumentation and preserve their ABI's.
// We will be stripping out access modifiers like view before we recompile
// post-instrumentation.
if (shell.test('-e', `${this.coverageDir}/build/contracts`)){
shell.rm('-Rf', `${this.coverageDir}/build/contracts`)
if (shell.test('-e', `${this.coverageDir}${this.buildDirPath}`)){
shell.rm('-Rf', `${this.coverageDir}${this.buildDirPath}`)
}
this.runCompileCommand();
this.originalArtifacts = this.loadArtifacts();
shell.rm('-Rf', `${this.coverageDir}/build/contracts`);
shell.rm('-Rf', `${this.coverageDir}${this.buildDirPath}`);
} catch (err) {
const msg = ('There was a problem generating the coverage environment: ');
@ -258,7 +259,7 @@ class App {
loadArtifacts() {
const artifacts = [];
shell.ls(`${this.coverageDir}/build/contracts/*.json`).forEach(file => {
shell.ls(`${this.coverageDir}${this.buildDirPath}/*.json`).forEach(file => {
const artifactPath = this.platformNeutralPath(file);
const artifactRaw = fs.readFileSync(artifactPath);
const artifact = JSON.parse(artifactRaw);
@ -273,7 +274,7 @@ class App {
* truffle automatically invokes those methods by `.call`, based on the ABI sig.
*/
modifyArtifacts(){
shell.ls(`${this.coverageDir}/build/contracts/*.json`).forEach((file, index) => {
shell.ls(`${this.coverageDir}${this.buildDirPath}/*.json`).forEach((file, index) => {
const artifactPath = this.platformNeutralPath(file);
const artifactRaw = fs.readFileSync(artifactPath);
const artifact = JSON.parse(artifactRaw);

Loading…
Cancel
Save