modifyManifest.js 724 B

12345678910111213141516171819202122232425262728
  1. const fs = require('fs');
  2. const manifestPath = process.env.UNI_INPUT_DIR + '/manifest.json';
  3. let Manifest = fs.readFileSync(manifestPath, { encoding: 'utf-8' });
  4. function replaceManifest(value, remove) {
  5. let data = JSON.parse(Manifest)
  6. let newValue = JSON.parse(value)
  7. if (remove === 'delete') {
  8. delete data['mp-weixin'].plugins['live-player-plugin'];
  9. } else {
  10. if (data['mp-weixin'].plugins['live-player-plugin']) return;
  11. data['mp-weixin'].plugins = {
  12. ...data['mp-weixin'].plugins,
  13. ...newValue
  14. }
  15. }
  16. Manifest = JSON.stringify(data)
  17. fs.writeFileSync(manifestPath, Manifest, {
  18. "flag": "w"
  19. })
  20. }
  21. export default replaceManifest