2020-08-14 08:11:58 +00:00
|
|
|
const { execSync } = require('child_process')
|
|
|
|
const fs = require('fs')
|
|
|
|
const path = require('path')
|
|
|
|
|
|
|
|
const platforms = require('./platforms')
|
|
|
|
const updatePackageJson = require('./update-package')
|
|
|
|
|
|
|
|
const { version } = require('../package.json')
|
|
|
|
|
|
|
|
updatePackageJson(path.join(__dirname, '..', 'package.json'), {
|
|
|
|
optionalDependencies: platforms.reduce((acc, cur) => {
|
2020-08-25 03:16:54 +00:00
|
|
|
acc[`rs-diff-${cur}`] = `^${version}`
|
2020-08-14 08:11:58 +00:00
|
|
|
return acc
|
|
|
|
}, {}),
|
|
|
|
})
|
|
|
|
|
|
|
|
for (const name of platforms) {
|
|
|
|
const pkgDir = path.join(__dirname, '..', 'npm', name)
|
|
|
|
const filename = `index.${name}.node`
|
2020-08-25 07:27:30 +00:00
|
|
|
if (!fs.existsSync(path.join(__dirname, '..', filename))) continue
|
2020-08-25 03:38:13 +00:00
|
|
|
const bindingFile = fs.readFileSync(path.join(__dirname, '..', filename))
|
2020-08-14 08:11:58 +00:00
|
|
|
fs.writeFileSync(path.join(pkgDir, filename), bindingFile)
|
|
|
|
execSync('npm publish', {
|
|
|
|
cwd: pkgDir,
|
|
|
|
env: process.env,
|
|
|
|
stdio: 'inherit',
|
|
|
|
})
|
|
|
|
}
|