fix: flake in shelljs scripts during postinstall (#19678)

This commit is contained in:
Tim Griesser
2022-01-12 19:48:12 -05:00
committed by GitHub
parent a9d0bc952b
commit 4915d65780
2 changed files with 16 additions and 8 deletions

View File

@@ -1,8 +1,13 @@
const shelljs = require('shelljs')
const fs = require('fs-extra')
const path = require('path')
const { includeTypes } = require('./utils')
shelljs.rm('-rf', 'build')
fs.removeSync(path.join(__dirname, '..', 'build'))
includeTypes.map((m) => {
shelljs.rm('-rf', `types/${m}`)
includeTypes.forEach((folder) => {
try {
fs.removeSync(path.join(__dirname, '..', 'types', folder))
} catch (e) {
//
}
})

View File

@@ -2,13 +2,14 @@
// @ts-check
/* eslint-disable no-console */
const fs = require('fs-extra')
const { includeTypes } = require('./utils')
const shell = require('shelljs')
const fs = require('fs')
const { join } = require('path')
const resolvePkg = require('resolve-pkg')
require('./clean')
shell.set('-v') // verbose
shell.set('-e') // any error is fatal
@@ -19,10 +20,12 @@ shell.set('-e') // any error is fatal
// yet we do not install "@types/.." packages with "npm install cypress"
// because they can conflict with user's own libraries
fs.ensureDirSync(join(__dirname, '..', 'types'))
includeTypes.forEach((folder) => {
const source = resolvePkg(`@types/${folder}`, { cwd: join(__dirname, '..', '..') })
shell.cp('-R', source, 'types')
fs.copySync(source, join(__dirname, '..', 'types', folder))
})
// jQuery v3.3.x includes "dist" folder that just references back to itself
@@ -72,7 +75,7 @@ shell.sed('-i', 'from \'sinon\';', 'from \'../sinon\';', sinonChaiFilename)
// copy experimental network stubbing type definitions
// so users can import: `import 'cypress/types/net-stubbing'`
shell.cp(resolvePkg('@packages/net-stubbing/lib/external-types.ts'), 'types/net-stubbing.ts')
fs.copySync(resolvePkg('@packages/net-stubbing/lib/external-types.ts'), 'types/net-stubbing.ts')
// https://github.com/cypress-io/cypress/issues/18069
// To avoid type clashes, some files should be commented out entirely by patch-package