-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (30 loc) · 925 Bytes
/
index.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
36
37
38
#!/usr/bin/env node
const exect = require('child_process').exec;
const path = require('path');
const fs = require('fs');
const mainPath = path.dirname(fs.realpathSync(__filename));
const soundPath = path.join(mainPath, './mlg-airhorn');
const mlgHorn = function (){
const linuxcmd = 'paplay '+soundPath+'.ogg';
const windowscmd = path.join(mainPath, './forWindows.vbs')+' '+soundPath+'.mp3';
const maccmd = 'afplay '+soundPath+'.mp3';
const platform = process.platform;
if(platform === 'linux'){
return exec(linuxcmd);
}
else if(platform === 'win32'){
return exec(windowscmd);
} else if(platform === 'darwin'){
return exec(maccmd);
}
function exec(cmd){
return exect(cmd, function (error, stdout, stderr) {
if(error)
console.error(error);
});
}
}
module.exports = mlgHorn;
if (!module.parent) {
mlgHorn();
}