Skip to content

Commit 914eaab

Browse files
committed
feat: create extension tsconfig.json file if needed
if there is a `tsconfig.json` in the root of the project, then create `tsconfig.json` that extends it and includes Cypress folder.
1 parent 5249d87 commit 914eaab

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/add-plugin.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ if (amDependency) {
5757

5858
const addTSConfigFile = () => {
5959
const tsConfigFilename = path.join(root, 'tsconfig.json')
60+
6061
if (!fs.existsSync(tsConfigFilename)) {
6162
console.log('cannot find tsconfig.json, creating default')
6263
const tsConfig = {
@@ -66,6 +67,14 @@ if (amDependency) {
6667
fs.writeFileSync(tsConfigFilename, text)
6768
} else {
6869
console.log('file %s already exists', tsConfigFilename)
70+
console.log('create only an extension tsconfig in the cypress folder')
71+
const toFile = path.join(cypressFolder, 'tsconfig.json')
72+
const tsConfig = {
73+
extends: '../tsconfig.json',
74+
include: ['../node_modules/cypress', '*/*.ts']
75+
}
76+
const text = JSON.stringify(tsConfig, null, 2) + '\n'
77+
fs.writeFileSync(toFile, text)
6978
}
7079
}
7180

0 commit comments

Comments
 (0)