Skip to content

Commit

Permalink
Try to update /tests/index.html only if it exists (guard from prod bu…
Browse files Browse the repository at this point in the history
…ild failures)
  • Loading branch information
Ruslan Zavacky committed Feb 24, 2017
1 parent a67384c commit c5e7ef0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions index.js
Expand Up @@ -21,7 +21,11 @@ module.exports = {
let testIndexFilePath = build.directory + '/tests/index.html';

let indexFile = fs.readFileSync(indexFilePath, {encoding: 'utf-8'});
let testIndexFile = fs.readFileSync(testIndexFilePath, {encoding: 'utf-8'});

let testIndexFile;
if (fs.existsSync(testIndexFilePath)) {
testIndexFile = fs.readFileSync(testIndexFilePath, {encoding: 'utf-8'});
}

let files = fs.readdirSync(build.directory + '/assets');
let totalFiles = files.length;
Expand All @@ -41,13 +45,16 @@ module.exports = {
}

let assetMapContent = null;

if (assetFileName) {
assetMapContent = `"${fingerprintPrepend + 'assets/' + assetFileName}"`;
}

fs.writeFileSync(indexFilePath, indexFile.replace(/__asset_map_placeholder__/, assetMapContent));
fs.writeFileSync(testIndexFilePath, testIndexFile.replace(/__asset_map_placeholder__/, assetMapContent));

if (testIndexFile) {
fs.writeFileSync(testIndexFilePath, testIndexFile.replace(/__asset_map_placeholder__/, assetMapContent));
}
},

contentFor(type, config) {
Expand Down

0 comments on commit c5e7ef0

Please sign in to comment.