From 342120727632363efebbb78befb684825d3a9b6a Mon Sep 17 00:00:00 2001 From: cgewecke Date: Sun, 22 Sep 2019 21:00:52 -0700 Subject: [PATCH] Add --temp command flag (#414) --- README.md | 1 + dist/plugin-assets/plugin.utils.js | 2 +- test/units/truffle/flags.js | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7f00825..dae71a8 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ truffle run coverage [options] | file | `--file="test/registry/*.js"` | Filename or glob describing a subset of JS tests to run. (Globs must be enclosed by quotes.)| | solcoverjs | `--solcoverjs ./../.solcover.js` | Relative path from working directory to config. Useful for monorepo packages that share settings. (Path must be "./" prefixed) | | network | `--network development` | Use network settings defined in the Truffle config | +| temp | `--temp build` | :warning: *Use with caution* :warning:. Disposable folder to store compilation artifacts in. Useful when your test setup scripts include hard-coded paths to a build directory. | | version | | Version info | | help | | Usage notes | diff --git a/dist/plugin-assets/plugin.utils.js b/dist/plugin-assets/plugin.utils.js index 18e5210..948013a 100644 --- a/dist/plugin-assets/plugin.utils.js +++ b/dist/plugin-assets/plugin.utils.js @@ -85,7 +85,7 @@ function toRelativePath(pathToFile, pathToParent){ function getTempLocations(config){ const cwd = config.working_directory; const contractsDirName = '.coverage_contracts'; - const artifactsDirName = '.coverage_artifacts'; + const artifactsDirName = config.temp || '.coverage_artifacts'; return { tempContractsDir: path.join(cwd, contractsDirName), diff --git a/test/units/truffle/flags.js b/test/units/truffle/flags.js index af1cadd..18d3c79 100644 --- a/test/units/truffle/flags.js +++ b/test/units/truffle/flags.js @@ -211,6 +211,20 @@ describe('Truffle Plugin: command line options', function() { ); }); + it('--coverageArtifacts', async function(){ + truffleConfig.logger = mock.testLogger; + + truffleConfig.temp = 'special_location'; + + mock.install('Simple', 'simple.js', solcoverConfig); + await plugin(truffleConfig); + + assert( + mock.loggerOutput.val.includes("/special_location/contracts"), + `Should write artifacts to "special_location": ${mock.loggerOutput.val}` + ); + }); + it('--network (network_id mismatch in configs)', async function(){ truffleConfig.logger = mock.testLogger;