-
Notifications
You must be signed in to change notification settings - Fork 0
/
postinstall.js
30 lines (27 loc) · 918 Bytes
/
postinstall.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
/**
* This will download the ffprobe binary for the current
* platform that is running the script.
*/
const ffbinaries=require('ffbinaries');
const path=require('path');
const fs=require('fs');
function download(callback) {
var platform=ffbinaries.detectPlatform();
var dest=__dirname + path.sep + 'bin' + path.sep;
var binaryfilename='ffprobe'+(platform.substr(0,3)=='win'?'.exe':'');
if( ! fs.existsSync(dest+binaryfilename) ) {
ffbinaries.downloadFiles('ffprobe', {destination: dest}, (err, data) => {
console.log('Downloading ffprobe binary to: '+dest);
callback(err, data);
});
} else {
console.log(`Binary already exists at ${dest}${binaryfilename}, no action taken!`);
}
}
download(function(err, data) {
if (err) {
console.log('Download failed.', err);
} else {
console.log('Download successful.');
}
});