Skip to content

Commit

Permalink
fix(revision match): fix overclock revision match
Browse files Browse the repository at this point in the history
Merge pull request #13 from RatherSlowTurtle/fix/overclock-revision-match

fix(revision match): fix overclock revision match
  • Loading branch information
jcane86 committed Jan 25, 2020
2 parents bbf1e51 + c4d151e commit c1721bc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ var getPiRevision = function () {
var revision;
var version;
fs.readFileSync('/proc/cpuinfo').toString().split(/\r?\n/).forEach(function (line) {
// Match a line of the form 'Revision : 0002' while ignoring extra info in front of the revsion (like 1000 when
// the Pi was over - volted
revision = line.match(/Revision\s+:\s+((?:\w)*\w{4})$/);
// Match a line of the form 'Revision : 0002' while ignoring extra info in front of the revision (like 1000xxxx or 1xxxxxx when
// the Pi was over - volted)
revision = line.match(/Revision\s+:\s+(?:1000|1|)(\w{4,6})$/);
if(revision) {
try {
version = require('./versions.json')[revision[1]];
Expand Down
18 changes: 18 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ describe('my module', function( done ) {
done();
});

it('should identify an overclocked device', function() {
['10000002', '1920093'].forEach(function(revision) {
var rpi = proxyquire('../lib/index.js', {
'fs': {
readFileSync: function () {
return 'Revision : ' + revision;
}
}
});
expect(rpi.revision).to.exist;
expect(rpi.relDate).to.exist;
expect(rpi.model).to.exist;
expect(rpi.PCBRev).to.exist;
expect(rpi.memory).to.exist;
expect(rpi.notes).to.exist;
});
});

var rev = "";
for (revision in versions){
rev = revision;
Expand Down

0 comments on commit c1721bc

Please sign in to comment.