Merge pull request #44 from sc-forks/copy-all-folders

Copy all directories when setting up coverageEnv
pull/46/head
c-g-e-w-e-k-e- 8 years ago committed by GitHub
commit 82cac373c7
  1. 1
      README.md
  2. 13
      bin/exec.js

@ -75,6 +75,7 @@ can be useful if you are using a different vm like the [sc-forks version of pyet
+ **dir**: *{ String }* : Solidity-coverage usually looks for `contracts` and `test` folders in your root + **dir**: *{ String }* : Solidity-coverage usually looks for `contracts` and `test` folders in your root
directory. `dir` allows you to define a relative path from the root directory to those assets. directory. `dir` allows you to define a relative path from the root directory to those assets.
`dir: "./<dirname>"` would tell solidity-coverage to look for `./<dirname>/contracts/` and `./<dirname>/test/` `dir: "./<dirname>"` would tell solidity-coverage to look for `./<dirname>/contracts/` and `./<dirname>/test/`
+ **copyNodeModules**: *{ Boolean }* : When true, will copy `node_modules` into the coverage environment. False by default, and may significantly increase the time for coverage to complete if enabled. Only enable if required.
**Example .solcover.js config file** **Example .solcover.js config file**
```javascript ```javascript

@ -61,6 +61,7 @@ const config = reqCwd.silent('./.solcover.js') || {};
const workingDir = config.dir || '.'; // Relative path to contracts folder const workingDir = config.dir || '.'; // Relative path to contracts folder
let port = config.port || 8555; // Port testrpc listens on let port = config.port || 8555; // Port testrpc listens on
const accounts = config.accounts || 35; // Number of accounts to testrpc launches with const accounts = config.accounts || 35; // Number of accounts to testrpc launches with
const copyNodeModules = config.copyNodeModules || false; // Whether we copy node_modules when making coverage environment
// Silence shell and script logging (for solcover's unit tests / CI) // Silence shell and script logging (for solcover's unit tests / CI)
if (config.silent) { if (config.silent) {
@ -78,10 +79,16 @@ try {
// migrations/ // migrations/
// truffle.js // truffle.js
let files = shell.ls(`${workingDir}`);
const nmIndex = files.indexOf('node_modules');
if (!config.copyNodeModules && nmIndex > -1) {
files.splice(nmIndex, 1); // Removes node_modules from array.
}
files = files.map(file => `${workingDir}/` + file);
shell.mkdir(`${coverageDir}`); shell.mkdir(`${coverageDir}`);
shell.cp('-R', `${workingDir}/contracts`, `${coverageDir}`); shell.cp('-R', files, `${coverageDir}`);
shell.cp('-R', `${workingDir}/test`, `${coverageDir}`);
shell.cp('-R', `${workingDir}/migrations`, `${coverageDir}`);
const truffleConfig = reqCwd.silent(`${workingDir}/truffle.js`); const truffleConfig = reqCwd.silent(`${workingDir}/truffle.js`);

Loading…
Cancel
Save