"use strict"; const { errorResult } = require("../../text-parser"); const createRegexParser = require("../../text-parser-regex"); const errors = require("../errors"); module.exports = function (devicePath) { return function handleDeviceInUse(command) { return command.expectOnStderr(createRegexParser(/Can't initialize physical volume "([^"]+)" of volume group "([^"]+)" without -ff/, (match) => { let [ _device, existingVolumeGroup ] = match.subMatches; return errorResult(new errors.DeviceInUse(`Specified device '${devicePath}' is already in use as a Physical Volume in another Volume Group (${existingVolumeGroup})`, { volume: { device: devicePath, volumeGroup: existingVolumeGroup } })); })); }; };