public function removePackage(array $packageNames, $areDevPackages = false)
    {
        $packages = $this->formatPackageNames($packageNames);
        $file = $this->embeddedComposer->getExternalComposerFilename();
        $jsonFile = new JsonFile($file);
        $json = new JsonConfigSource($jsonFile);
        $composerDefinition = $jsonFile->read();
        $type = $areDevPackages ? 'require-dev' : 'require';

        foreach ($packages as $name => $version) {
            if (isset($composerDefinition[$type][$name])) {
                $json->removeLink($type, $name);
                unset($composerDefinition[$type][$name]);

                continue;
            }

            $this->io->writeError(sprintf(
               'Package: "%s" is not required and has not been removed.',
               $name
            ));
        }

        return $composerDefinition[$type];
    }