tabby/scripts/prepackage-plugins.js

26 lines
813 B
JavaScript
Raw Normal View History

2017-05-01 06:01:12 +08:00
#!/usr/bin/env node
const rebuild = require('electron-rebuild').default
const sh = require('shelljs')
const path = require('path')
const fs = require('fs')
const vars = require('./vars')
2017-06-10 06:29:16 +08:00
const log = require('npmlog')
2017-05-01 06:01:12 +08:00
let target = path.resolve(__dirname, '../builtin-plugins')
sh.mkdir('-p', target)
fs.writeFileSync(path.join(target, 'package.json'), '{}')
sh.cd(target)
vars.builtinPlugins.forEach(plugin => {
2017-06-10 06:29:16 +08:00
log.info('install', plugin)
sh.cp('-r', path.join('..', plugin), '.')
sh.rm('-rf', path.join(plugin, 'node_modules'))
sh.cd(plugin)
sh.exec(`npm install --only=prod`)
log.info('rebuild', 'native')
if (fs.existsSync('node_modules')) {
2017-06-24 05:52:51 +08:00
rebuild(path.resolve('.'), vars.electronVersion, process.arch, [], true)
2017-06-10 06:29:16 +08:00
}
sh.cd('..')
2017-05-01 06:01:12 +08:00
})
2017-07-01 06:54:55 +08:00
fs.unlinkSync(path.join(target, 'package.json'), '{}')