I am looking into it a little more but for starters does dpm() show the correct value for $dir
? Also, according to the documentation the trailing slash on $dir
is not supposed to be there.
code that is working for me:
$dir = DRUPAL_ROOT . '/sites/all/libraries';
$files = file_scan_directory($dir, '/.*\.js/');
dpm($files);