diff --git a/src/ncc/Classes/Runtime.php b/src/ncc/Classes/Runtime.php index 36daf32..fd00c99 100644 --- a/src/ncc/Classes/Runtime.php +++ b/src/ncc/Classes/Runtime.php @@ -205,10 +205,16 @@ } // Get the file contents and prepare it - $evaluated_code = IO::fread($required_file(preg_replace('/^<\?php|<\?PHP/', '', $required_file, 1))); - set_error_handler(function ($errno, $errstr, $errfile, $errline) use ($item, $package) + $evaluated_code = IO::fread($required_file); + + // Remove the PHP tags + $evaluated_code = preg_replace('/^<\?php|<\?PHP/', '', $evaluated_code, 1); + // Replace __DIR__ with the actual directory that the file is in + $evaluated_code = str_replace('__DIR__', sprintf('"%s"', dirname($required_file)), $evaluated_code); + + set_error_handler(function ($error_number, $message, $file, $line) use ($item, $package) { - throw new ImportException(sprintf('Failed to import "%s" from %s: %s', $item, $package, $errstr)); + throw new ImportException(sprintf('Fatal Evaluation Error: Failed to import "%s" from %s on %s:%s: %s', $item, $package, $file, $line, $message)); }); // Evaluate the code @@ -220,6 +226,10 @@ { throw new ImportException(sprintf('%s: Failed to import "%s" from %s: %s', $required_file, $item, $package, $e->getMessage()), $e); } + catch(ImportException $e) + { + throw $e; + } catch (Throwable $e) { throw new ImportException(sprintf('%s: Failed to import "%s" from %s: %s', $required_file, $item, $package, $e->getMessage()), $e); diff --git a/src/ncc/Managers/ProjectManager.php b/src/ncc/Managers/ProjectManager.php index 6d6951f..7f446e2 100644 --- a/src/ncc/Managers/ProjectManager.php +++ b/src/ncc/Managers/ProjectManager.php @@ -676,14 +676,7 @@ $path = substr($path, 0, -1); } - if($path === '') - { - $destination_path .= DIRECTORY_SEPARATOR . hash('crc32', $project_path); - } - else - { - $destination_path .= DIRECTORY_SEPARATOR . hash('crc32', $path); - } + $destination_path .= DIRECTORY_SEPARATOR . hash('crc32', $project_path); if(is_file($source_path)) {