-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostinstall.js
27 lines (21 loc) · 851 Bytes
/
postinstall.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const fs = require('fs')
const path = require('path')
let dir = path.resolve(__dirname, 'dist')
function loadModule(name) {
try { return require(name) } catch (e) { return undefined }
}
function copy(name) {
const src = path.join(dir, 'vue3', name)
const dest = path.join(dir, name)
let content = fs.readFileSync(src, 'utf-8')
try { fs.unlinkSync(dest) } catch (error) { }
fs.writeFileSync(dest, content, 'utf-8')
}
const Vue = loadModule('vue')
if (!Vue || typeof Vue.version !== 'string') {
console.warn('[single-file-upload-for-vue] Vue is not found. Please run "npm install vue" to install.')
} else if (Vue.version.startsWith('3.')) {
console.log(`[single-file-upload-for-vue] installing for vue3 from dir ${dir}`)
copy('single-file-upload-for-vue.esm.js')
copy('single-file-upload-for-vue.ssr.js')
}