postinstall.cjs 648 B

123456789101112131415161718192021
  1. const fs = require('fs')
  2. const { switchVersion, loadModule } = require('./utils.cjs')
  3. const Vue = loadModule('vue')
  4. if (fs.existsSync('.local'))
  5. console.log('Currently, it is the local development environment, not doing anything.')
  6. else if (!Vue || typeof Vue.version !== 'string')
  7. console.warn('[v-code-diff] Vue is not found. Please run "npm install vue" to install.')
  8. else if (Vue.version.startsWith('2.7.'))
  9. switchVersion('2.7')
  10. else if (Vue.version.startsWith('2.'))
  11. switchVersion('2')
  12. else if (Vue.version.startsWith('3.'))
  13. switchVersion('3')
  14. else console.warn(`[v-code-diff] Vue version v${Vue.version} is not suppported.`)