A tiny, zero-dependency utility providing hardware revision information for Raspberry Pi devices. All information is parsed from the device's revision code located in /proc/cpuinfo
.
yarn add pirev
or
npm install pirev
const pirev = require('pirev');
pirev.getInfo().then(({ revision }) => {
console.log(`Raspberry Pi ${revision.type}`);
});
const pirev = require('pirev');
const { revision } = pirev.getInfoSync();
console.log(`Raspberry Pi ${revision.type}`);
Running the utility on a device which is not a Raspberry Pi will result in an error being thrown.
pirev.getInfo()
.then(({ revision }) => console.log(`Raspberry Pi ${revision.type}`))
.catch(() => console.warn('Not a Raspberry Pi device!'));
or
try {
const { revision } = pirev.getInfoSync();
console.log(`Raspberry Pi ${revision.type}`);
} catch {
console.warn('Not a Raspberry Pi device!');
}