public function mergeScripts(RootPackageInterface $root, PluginState $state)
    {
        $scripts = $this->package->getScripts();
        if (!$state->shouldMergeScripts() || empty($scripts)) {
            return;
        }

        $rootScripts = $root->getScripts();
        $unwrapped = self::unwrapIfNeeded($root, 'setScripts');

        if ($state->replaceDuplicateLinks()) {
            $unwrapped->setScripts(
                array_merge($rootScripts, $scripts)
            );
        } else {
            $unwrapped->setScripts(
                array_merge($scripts, $rootScripts)
            );
        }
    }