linkBin.js 704 B

123456789101112131415161718192021
  1. // cross-platform executable link, mostly for Windows
  2. // this file is dev-only.
  3. const fs = require('fs-extra')
  4. const path = require('path')
  5. const cmdShim = require('util').promisify(require('cmd-shim'))
  6. exports.linkBin = async (src, dest) => {
  7. if (!process.env.VUE_CLI_TEST && !process.env.VUE_CLI_DEBUG) {
  8. throw new Error(`linkBin should only be used during tests or debugging.`)
  9. }
  10. if (process.platform === 'win32' && !process.env.CI) {
  11. // not doing mutex lock because this is only used in dev and the
  12. // src will not be modified
  13. await cmdShim(src, dest)
  14. } else {
  15. await fs.ensureDir(path.dirname(dest))
  16. await fs.symlink(src, dest)
  17. await fs.chmod(dest, '755')
  18. }
  19. }