Files
chatmail-core/node/scripts/install.js
2022-05-13 21:25:35 +02:00

28 lines
1.0 KiB
JavaScript

const {execSync} = require('child_process')
const {existsSync} = require('fs')
const {join} = require('path')
const run = (cmd) => {
console.log('[i] running `' + cmd + '`')
execSync(cmd, {stdio: 'inherit'})
}
if (!existsSync(join(__dirname, '..', 'deltachat-core-rust'))) {
console.log('[i] deltachat-node/deltachat-core-rust doesn\'t exist, fetching submodule. If this fails, make sure git is installed')
run('npm run submodule')
}
// Build bindings
if (process.env.USE_SYSTEM_LIBDELTACHAT === 'true') {
console.log('[i] USE_SYSTEM_LIBDELTACHAT is true, rebuilding c bindings and using pkg-config to retrieve lib paths and cflags of libdeltachat')
run('npm run build:bindings:c:c')
} else {
console.log('[i] Building rust core & c bindings, if possible use prebuilds')
run('npm run install:prebuilds')
}
if (!existsSync(join(__dirname, '..', 'dist'))) {
console.log('[i] Didn\'t find already built typescript bindings. Trying to transpile them. If this fail, make sure typescript is installed ;)')
run('npm run build:bindings:ts')
}