-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcmd.js
executable file
·47 lines (39 loc) · 944 Bytes
/
cmd.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
39
40
41
42
43
44
45
46
47
#!/usr/bin/env node
var cp = require('child_process')
var vlcCommand = require('./')
var arg = process.argv[2]
if (!arg || arg === '--help' || arg === '-h') {
console.log(`
Usage:
vlc-command <option>
Options:
--open, -o Open VLC.
--path, -p Print VLC path.
--help, -h Print usage information.
--version, -v Print version.
`)
}
if (arg === '--path' || arg === '-p') {
vlcCommand(function (err, command) {
if (err) throw err
console.log(command)
})
}
if (arg === '--open' || arg === '-o') {
vlcCommand(function (err, command) {
if (err) throw err
if (process.platform === 'win32') {
cp.execFile(command, onExit)
} else {
cp.exec(command, onExit)
}
})
}
function onExit (err, stdout, stderr) {
console.log(stdout)
console.error(stderr)
if (err) throw err
}
if (arg === '--version' || arg === '-v') {
console.log(require('./package.json').version)
}