electron_video_sdk_preinstall.js 454 B

123456789101112131415161718
  1. const { arch } = process
  2. const fs = require('fs')
  3. const pkgPath = './package.json'
  4. const pkg = fs.readFileSync(pkgPath)
  5. let pkgObject = JSON.parse(pkg)
  6. pkgObject.config = {arch: `${arch}`}
  7. fs.writeFileSync(pkgPath, JSON.stringify(pkgObject, null, 2))
  8. fs.writeFile('.npmrc',`arch=${arch}`,'utf8',function (error) {
  9. if (error) {
  10. console.log(error)
  11. return false
  12. }
  13. fs.close(0, function() {
  14. console.log('write .npmrc file success')
  15. })
  16. })