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) {