public function addLocalDirectory($directory, $recursive = false)
    {
        if (!file_exists($directory) || !is_dir($directory)) {
            throw new Exception\InvalidArgumentException(sprintf(
                'The directory "%s" does not exists.',
                $directory
            ));
        }

        if ($recursive) {
            $iterator = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($directory)
            );
        } else {
            $iterator = new \DirectoryIterator($directory);
        }

        foreach ($iterator as $fileinfo) {
            if (!$fileinfo->isFile()) {
                continue;
            }
            
            $extension = $fileinfo->getExtension();
            if ($extension != 'js') {
                continue;
            }

            $this->addLocalFile($fileinfo->getPathname());
        }

        return $this;
    }