1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-12-21 07:41:39 +03:00
leon/scripts/setup/preinstall.js
2019-02-10 20:26:50 +08:00

20 lines
840 B
JavaScript

const fs = require('fs')
const os = require('os')
const { execSync } = require('child_process')
/**
* Trigger preinstall hook to remove DeepSpeech on Windows
*/
if (os.type().indexOf('Windows') !== -1) {
console.warn('\x1b[33m❗ %s\x1b[0m', 'The Leon\'s voice offline mode is not available on Windows')
console.info('\x1b[36m➡ %s\x1b[0m', 'Backing up package.json...')
fs.copyFileSync('package.json', 'package.json.backup')
console.log('\x1b[32m✔ %s\x1b[0m', 'package.json has been backed up')
console.info('\x1b[36m➡ %s\x1b[0m', 'Removing DeepSpeech dependency... Please wait, this might take several minutes...')
execSync('npm uninstall --save deepspeech')
console.log('\x1b[32m✔ %s\x1b[0m', 'DeepSpeech dependency has been removed.')
}
console.info('\x1b[36m➡ %s\x1b[0m', 'Running Leon\'s installation...')