From c5e7ef0c7bb71f0d3e040cf2fda5aefad02b6f4b Mon Sep 17 00:00:00 2001 From: Ruslan Zavacky Date: Fri, 24 Feb 2017 15:56:06 +0000 Subject: [PATCH] Try to update /tests/index.html only if it exists (guard from prod build failures) --- index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 606ce5e..2d42d5a 100644 --- a/index.js +++ b/index.js @@ -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; @@ -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) {