Skip to content

Commit

Permalink
Merge branch 'release/1.0.8' [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Gruber committed Feb 16, 2017
2 parents a528926 + e9679ca commit 03ca49a
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#Changelog

###1.0.8
- Only copy external assets if they do not already exist [mochawesome #76](https://github.com/adamgruber/mochawesome/issues/76)

###1.0.7
- Fix an issue where test context could not be viewed if `enableCode` option was `false`. [mochawesome #132](https://github.com/adamgruber/mochawesome/issues/132)
- Add an icon to indicate when a test has context
Expand Down
6 changes: 4 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ function getAssets() {
*/

function copyAssets(opts) {
// Copy the assets to the report location
// Copy the assets to the report location if they don't exist
var assetsDir = path.join(opts.reportDir, 'assets');
fs.copySync(externalAssetsDir, assetsDir);
if (!fs.existsSync(assetsDir)) {
fs.copySync(externalAssetsDir, assetsDir);
}
}

/**
Expand Down
6 changes: 4 additions & 2 deletions lib/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@ function getAssets() {
*/

function copyAssets(opts) {
// Copy the assets to the report location
// Copy the assets to the report location if they don't exist
const assetsDir = path.join(opts.reportDir, 'assets');
fs.copySync(externalAssetsDir, assetsDir);
if (!fs.existsSync(assetsDir)) {
fs.copySync(externalAssetsDir, assetsDir);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mochawesome-report-generator",
"version": "1.0.7",
"version": "1.0.8",
"description": "Generates gorgeous HTML reports from mochawesome reporter.",
"scripts": {
"lint": "eslint bin lib src/js src/components/**/*.js src/components/**/*.jsx test/**/*.js test/**/*.jsx",
Expand Down
10 changes: 9 additions & 1 deletion test/spec/lib/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ const outputFileSyncStub = sinon.stub();
const copySyncStub = sinon.stub();
const readFileSyncStub = sinon.stub();
const openerStub = sinon.stub();
const existsSyncStub = sinon.stub();
const mareport = proxyquire('../../../lib/src/main', {
'fs-extra': {
outputFile: outputFileStub,
outputFileSync: outputFileSyncStub,
copySync: copySyncStub,
readFileSync: readFileSyncStub
readFileSync: readFileSyncStub,
existsSync: existsSyncStub
},
opener: openerStub
});
Expand Down Expand Up @@ -98,6 +100,12 @@ describe('lib/main', () => {
expect(copySyncStub.called).to.equal(true);
});

it('doesn\'t copy assets if assetsDir already exists', () => {
existsSyncStub.returns(true);
mareport.createSync(testData, { inlineAssets: false });
expect(copySyncStub.called).to.equal(false);
});

it('inlines assets', () => {
mareport.createSync(testData, { inlineAssets: true });
expect(readFileSyncStub.called).to.equal(true);
Expand Down

0 comments on commit 03ca49a

Please sign in to comment.