-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-sox.js
35 lines (31 loc) · 858 Bytes
/
check-sox.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
33
34
35
import { exec } from 'child_process'
import os from 'os'
function installSox() {
const platform = os.platform()
let installCommand
if (platform === 'darwin') {
installCommand = 'brew install sox'
} else if (platform === 'linux') {
installCommand = 'sudo apt-get install -y sox libsox-fmt-all'
} else if (platform === 'win32') {
installCommand = 'choco install sox.portable'
} else {
console.error('Unsupported platform:', platform)
return
}
exec(installCommand, (error, stdout, stderr) => {
if (error) {
console.error(`Error installing SoX: ${error.message}`)
return
}
console.log(`SoX installed: ${stdout}`)
})
}
exec('sox --version', (error) => {
if (error) {
console.log('SoX not found, installing...')
installSox()
} else {
console.log('SoX is already installed.')
}
})