-
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpreinstall.js
More file actions
23 lines (18 loc) · 757 Bytes
/
preinstall.js
File metadata and controls
23 lines (18 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const { exec } = require( 'child_process' );
const bin = process.env.NODE_APP_BIN ?? 'vnstat';
exec( `${bin} --version`, ( err, res ) => {
if ( err ) {
console.warn( 'Warning: vnstat not found. This package requires vnStat >= v1.13 to be installed.' );
console.warn( 'Install vnStat from: https://github.com/vergoh/vnstat' );
return;
}
res.replace( /^vnStat (\d+)\.(\d+) /, ( s, major, minor ) => {
const majorNum = parseInt( major, 10 );
const minorNum = parseInt( minor, 10 );
if ( majorNum > 1 || ( majorNum === 1 && minorNum >= 13 ) ) {
return;
}
console.warn( `Warning: Wrong vnStat version: requires >= v1.13, but v${major}.${minor} installed` );
console.warn( `Command run: ${bin}` );
} );
} );