Skip to content

Commit

Permalink
+ proper propagating skippable sign
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Dec 26, 2016
1 parent 778096f commit 9f4362e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ public static function writeFile($path, array $data)
if (!file_exists(dirname($path))) {
mkdir(dirname($path), 0777, true);
}
$content = str_replace("'" . static::BASE_DIR_MARKER, '$baseDir . \'', Helper::exportVar($data));
$content = Helper::exportVar($data);
$content = str_replace("'" . static::BASE_DIR_MARKER, "\$baseDir . '", $content);
$content = str_replace("'?" . static::BASE_DIR_MARKER, "'?' . \$baseDir . '", $content);
static::putFile($path, "<?php\n\n\$baseDir = dirname(dirname(dirname(__DIR__)));\n\nreturn $content;\n");
}

Expand Down Expand Up @@ -218,7 +220,13 @@ public static function substitutePathes($data, $dir, $alias)
*/
protected static function substitutePath($path, $dir, $alias)
{
return (substr($path, 0, strlen($dir) + 1) === $dir . DIRECTORY_SEPARATOR) ? $alias . substr($path, strlen($dir)) : $path;
$skippable = strncmp($path, '?', 1) === 0 ? '?' : '';
if ($skippable) {
$path = substr($path, 1);
}
$result = (substr($path, 0, strlen($dir) + 1) === $dir . DIRECTORY_SEPARATOR) ? $alias . substr($path, strlen($dir)) : $path;

return $skippable . $result;
}

public function readConfig($name)
Expand Down

0 comments on commit 9f4362e

Please sign in to comment.