UNPKG

wix-style-react

Version:
35 lines (31 loc) 1.1 kB
const fs = require('fs'); const path = require('path'); const packageLockPath = path.resolve(__dirname, '../package-lock.json'); const packagesToOverride = [ '@types/enzyme', '@types/hoist-non-react-statics', '@types/reach__router', '@types/react-syntax-highlighter', '@types/react-test-renderer', '@types/react-transition-group', ]; if (fs.existsSync(packageLockPath)) { const reactTypesVersion = '^16.14.26'; const execa = require('execa'); const raw = fs.readFileSync(packageLockPath, 'utf8'); const json = JSON.parse(raw); json.dependencies['@types/hoist-non-react-statics'].dependencies = {}; for (const name of packagesToOverride) { json.dependencies[name].requires = { ...json.dependencies[name].requires, '@types/react': reactTypesVersion, }; } fs.writeFileSync('package-lock.json', JSON.stringify(json)); const prettierPath = path.resolve(__dirname, '../node_modules/.bin/prettier'); execa(prettierPath, ['--write', packageLockPath]) .then(result => console.log(result)) .catch(error => { console.log(error); }); }