1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2025-02-02 09:58:23 +01:00

Add a check to 'arc liberate' for loose .php files in the library root

Summary: @koolvin ran into this and was justifiably confused.

Test Plan: Put some random .php file in src/, ran arc liberate src/, got warned.

Reviewers: btrahan, Koolvin

Reviewed By: btrahan

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1878
This commit is contained in:
epriestley 2012-03-13 11:17:28 -07:00
parent 024d108661
commit ec9a3ddb23

View file

@ -131,6 +131,8 @@ EOTEXT
$readable = Filesystem::readablePath($path);
echo "Using library root at '{$readable}'...\n";
$this->checkForLooseFiles($path);
if ($this->getArgument('all')) {
echo "Dropping module cache...\n";
Filesystem::remove($path.'/.phutil_module_cache');
@ -339,4 +341,25 @@ EOTEXT
return (int)$unresolved;
}
/**
* Sanity check to catch people putting class files in the root of a libphutil
* library.
*/
private function checkForLooseFiles($path) {
foreach (Filesystem::listDirectory($path) as $item) {
if (!preg_match('/\.php$/', $item)) {
// Not a ".php" file.
continue;
}
if (preg_match('/^__/', $item)) {
// Has magic '__' prefix.
continue;
}
echo phutil_console_wrap(
"WARNING: File '{$item}' is not in a module and won't be loaded. ".
"Put source files in subdirectories, not the top level directory.\n");
}
}
}