28 lines
1.0 KiB
JavaScript
28 lines
1.0 KiB
JavaScript
|
const fs = require('fs')
|
||
|
const path = require('path')
|
||
|
|
||
|
|
||
|
// 脚本执行之前的操作
|
||
|
var iosUrl = "https://apps.apple.com/kr/app/id6467117398"
|
||
|
var androidUrl = "https://play.google.com/store/apps/details?id=com.mxdzzkr.google"
|
||
|
|
||
|
|
||
|
// 清空dist目录
|
||
|
|
||
|
const isExists = fs.existsSync(path.join(__dirname, 'dist'))
|
||
|
if (isExists) {
|
||
|
fs.rmdirSync(path.join(__dirname, 'dist'), { recursive: true })
|
||
|
}
|
||
|
if (!isExists) {
|
||
|
fs.mkdirSync(path.join(__dirname, 'dist'))
|
||
|
}
|
||
|
|
||
|
|
||
|
// 1. 替换mraid_support.js文件中的iosUrl和androidUrl
|
||
|
var mraid_support_js = fs.readFileSync(path.join(__dirname, 'networks', 'mraid_support.js'), 'utf8')
|
||
|
// 匹配var iosUrl = "", var iosurl "" 结尾的
|
||
|
mraid_support_js = mraid_support_js.replace(/var iosUrl = ".*"/g, `var iosUrl = "${iosUrl}"`)
|
||
|
// 匹配var androidUrl = "", var androidurl "" 结尾的
|
||
|
mraid_support_js = mraid_support_js.replace(/var androidUrl = ".*"/g, `var androidUrl = "${androidUrl}"`)
|
||
|
fs.writeFileSync(path.join(__dirname, 'networks', 'mraid_support.js'), mraid_support_js, 'utf8')
|