mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-26 02:47:17 +00:00
- [osx] remove the 0x from productID and locationId and vendorId - [linux] remove the starting 0x from any values, small refactor - [linux] Fixup output using the hex encoded fields - [windows] Grab the serial number from the pnp id - Isolate list functions to their own platform files (c++) - Better ensure our serialports fields are present closes #1220
33 lines
676 B
JavaScript
33 lines
676 B
JavaScript
// Mocks fs.read for listLinux
|
|
|
|
'use strict';
|
|
|
|
const EventEmitter = require('events');
|
|
const proxyquire = require('proxyquire');
|
|
const Readable = require('stream').Readable;
|
|
let mockPorts;
|
|
|
|
proxyquire.noPreserveCache();
|
|
const listLinux = proxyquire('../../lib/bindings/linux-list', {
|
|
child_process: {
|
|
spawn() {
|
|
const event = new EventEmitter();
|
|
const stream = new Readable();
|
|
event.stdout = stream;
|
|
stream.push(mockPorts);
|
|
stream.push(null);
|
|
return event;
|
|
}
|
|
}
|
|
});
|
|
proxyquire.preserveCache();
|
|
|
|
listLinux.setPorts = (ports) => {
|
|
mockPorts = ports;
|
|
};
|
|
|
|
listLinux.reset = () => {
|
|
mockPorts = {};
|
|
};
|
|
|
|
module.exports = listLinux;
|