From 742dd63371a963d8dd4fe734909a7c51f2579bb3 Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Sun, 17 Jul 2022 23:08:55 +0100 Subject: [PATCH 1/2] fix: only parse specified file extensions --- lib/cypress-plugin/modifySpec.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/cypress-plugin/modifySpec.js b/lib/cypress-plugin/modifySpec.js index abe03ac..ec3e543 100644 --- a/lib/cypress-plugin/modifySpec.js +++ b/lib/cypress-plugin/modifySpec.js @@ -22,6 +22,13 @@ const path = require('path'); * @returns {String} - New spec file with added before block */ module.exports = (fileContents, version, source, target) => { + const re = /(?:\.([^.]+))?$/; + + // Only parse the following files. + if (!['js', 'jsx', 'ts', 'tsx'].includes(re.exec(source)[0])) { + return fileContents; + } + const beforeBlock = esprima.parseScript(` before(() => { const path = require('path'); @@ -36,6 +43,8 @@ module.exports = (fileContents, version, source, target) => { }); `).body[0]; + console.log(fileContents); + const parsed = esprima.parseModule(fileContents); const parsedFileWithInsert = { From 43e61b9ff4f651b6ab83b572e6e5fcf29d721b9d Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Sun, 17 Jul 2022 23:09:54 +0100 Subject: [PATCH 2/2] fix: remove console.log --- lib/cypress-plugin/modifySpec.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/cypress-plugin/modifySpec.js b/lib/cypress-plugin/modifySpec.js index ec3e543..b0e4bae 100644 --- a/lib/cypress-plugin/modifySpec.js +++ b/lib/cypress-plugin/modifySpec.js @@ -43,8 +43,6 @@ module.exports = (fileContents, version, source, target) => { }); `).body[0]; - console.log(fileContents); - const parsed = esprima.parseModule(fileContents); const parsedFileWithInsert = {