You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
642 B
JavaScript
25 lines
642 B
JavaScript
"use strict";
|
|
|
|
const { errorResult } = require("../../text-parser");
|
|
const createRegexParser = require("../../text-parser-regex");
|
|
|
|
const errors = require("../errors");
|
|
|
|
module.exports = function (devicePath) {
|
|
function makeError() {
|
|
return errorResult(new errors.InvalidPath(`Specified device '${devicePath}' does not exist`, {
|
|
path: devicePath
|
|
}));
|
|
}
|
|
|
|
return function handleDeviceNotFound(command) {
|
|
return command
|
|
.expectOnStderr(createRegexParser(/Device .+ not found\./, () => {
|
|
return makeError();
|
|
}))
|
|
.expectOnStderr(createRegexParser(/No device found for .+\./, () => {
|
|
return makeError();
|
|
}));
|
|
};
|
|
};
|