123456789101112131415161718192021222324252627282930313233 |
- const fs = require('fs-extra')
- const loadPresetFromDir = require('./loadPresetFromDir')
- module.exports = async function loadRemotePreset (repository, clone) {
- const os = require('os')
- const path = require('path')
- const download = require('download-git-repo')
- const presetName = repository
- .replace(/((?:.git)?#.*)/, '')
- .split('/')
- .slice(-1)[0]
-
-
- .replace(/[:#]/g, '')
- const tmpdir = path.join(os.tmpdir(), 'vue-cli-presets', presetName)
-
-
- if (clone) {
- await fs.remove(tmpdir)
- }
- await new Promise((resolve, reject) => {
- download(repository, tmpdir, { clone }, err => {
- if (err) return reject(err)
- resolve()
- })
- })
- return await loadPresetFromDir(tmpdir)
- }
|