"use strict"; const Promise = require("bluebird"); const execBinary = require("../../exec-binary"); const forceFlags = require("../modifiers/force-flags"); const unattendedFlags = require("../modifiers/unattended-flags"); const handleDeviceNotFound = require("../modifiers/handle-device-not-found"); const handlePartitionExists = require("../modifiers/handle-partition-exists"); const handleDeviceInUse = require("../modifiers/handle-device-in-use"); module.exports = function ({ devicePath, force }) { return Promise.try(() => { return execBinary("pvcreate", [devicePath]) .asRoot() .requireResult() .withModifier((force === true) ? forceFlags : unattendedFlags) .withModifier(handleDeviceNotFound(devicePath)) .withModifier(handleDeviceInUse(devicePath)) .withModifier(handlePartitionExists(devicePath, "create a Physical Volume")) .execute(); }).then((_output) => { return true; }); };