mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-06 06:29:45 -06:00
Co-authored-by: Jessica Sachs <jess@jessicasachs.io> Co-authored-by: Barthélémy Ledoux <bart@cypress.io> Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com> Co-authored-by: Zach Bloomquist <github@chary.us> Co-authored-by: Dmitriy Kovalenko <dmtr.kovalenko@outlook.com> Co-authored-by: ElevateBart <ledouxb@gmail.com> Co-authored-by: Ben Kucera <14625260+Bkucera@users.noreply.github.com>
25 lines
551 B
JavaScript
25 lines
551 B
JavaScript
const fs = require('fs')
|
|
const glob = require('glob')
|
|
const minimist = require('minimist')
|
|
const path = require('path')
|
|
|
|
const args = minimist(process.argv.slice(2))
|
|
|
|
const packages = glob.sync('*/', {
|
|
cwd: path.join(process.cwd(), 'packages'),
|
|
})
|
|
.map((str) => {
|
|
return str.replace('/', '\\/')
|
|
})
|
|
.join('|')
|
|
|
|
const pattern = `(\'|")(.*\\.\\.\\/)(${packages})`
|
|
|
|
const re = new RegExp(pattern, 'g')
|
|
|
|
const text = fs.readFileSync(args.file, 'utf8')
|
|
|
|
const replacedText = text.replace(re, '$1@packages/$3')
|
|
|
|
fs.writeFileSync(args.file, replacedText)
|