forked from netease-kit/Kit-FullSearch-Electron
-
Notifications
You must be signed in to change notification settings - Fork 1
/
just-task.js
32 lines (31 loc) · 1.36 KB
/
just-task.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
28
29
30
31
32
const { task, option, logger, argv } = require('just-scripts')
const fs = require('fs')
const download = require('download')
const path = require('path')
task('install', () => {
return new Promise((resolve, reject) => {
const curPkgMeta = require(path.join(__dirname, 'package.json'))
const localPath = path.join(__dirname, 'lib')
// const downloadUrl = `http://yx-web.nos.netease.com/package/electron-tokenizer-plugin_v${curPkgMeta.version}.tar.gz`
const downloadUrl = `http://yx-web.nos.netease.com/package/electron-tokenizer-plugin_v2.1.1.tar.gz`
download(downloadUrl, localPath, {
extract: true
}).then(() => {
const platform = process.env.npm_config_target_platform || process.platform
const arch = process.env.npm_config_target_arch || process.arch
logger.info(`[install] Download prebuilt binaries from ${downloadUrl}`)
logger.info(`[install] Target platform: ${platform}`)
logger.info(`[install] Target arch: ${arch}`)
if (platform === 'win32') {
const src = path.join(localPath, arch, 'simple.dll')
const dst = path.join(localPath, 'simple.dll')
logger.info(`Copy win32 lib from ${src} to ${dst}`)
fs.copyFileSync(src, dst)
}
resolve()
}).catch(err => {
logger.warn(`[install] Failed to download package from: ${downloadUrl}`)
reject()
})
})
})