"use strict"; const { errorResult } = require("../../text-parser"); const createRegexParser = require("../../text-parser-regex"); const errors = require("../errors"); module.exports = function (devicePath, action) { return function handlePartitionExists(command) { return command.expectOnStderr(createRegexParser(/WARNING: [a-z]+ signature detected on/, () => { return errorResult(new errors.PartitionExists(`Refused to ${action}, as a partition or partition table already exists on device '${devicePath}'`, { path: devicePath })); })); }; };