From a15ced0f5b29a1a2d37c9dd79a9986512ba4f084 Mon Sep 17 00:00:00 2001 From: Maxim Karanaev Date: Sun, 15 Nov 2020 06:34:44 +0300 Subject: [PATCH] Add bin dir --- .gitignore | 1 + bin/.gitkeep | 0 src/Binding/Binding.php | 14 +++++++++----- src/Composer/PostScript.php | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 bin/.gitkeep diff --git a/.gitignore b/.gitignore index 3af59f7..11fbb8f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .idea/ vendor/ composer.lock +bin/tonclient.* diff --git a/bin/.gitkeep b/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/Binding/Binding.php b/src/Binding/Binding.php index 06f6721..3cb94ef 100644 --- a/src/Binding/Binding.php +++ b/src/Binding/Binding.php @@ -84,19 +84,23 @@ public function getLibraryInterface(): string public static function createDefault(): self { $paths = [ - 'linux' => __DIR__ . '/../../vendor/bin/tonclient.so', - 'darwin' => __DIR__ . '/../../vendor/bin/tonclient.dylib', - 'win32' => __DIR__ . '/../../vendor/bin/tonclient.dll', + 'linux' => __DIR__ . '/../../bin/tonclient.so', + 'darwin' => __DIR__ . '/../../bin/tonclient.dylib', + 'win32' => __DIR__ . '/../../bin/tonclient.dll', ]; $os = strtolower(PHP_OS); - if (!isset($paths[$os]) || !file_exists($paths[$os])) { - throw new ConfigException(sprintf('TON SDK library not found by path %s.', $paths[$os])); + if (!isset($paths[$os])) { + throw new ConfigException(sprintf('TON SDK library not found by OS %s.', $os)); } $path = str_replace('/', DIRECTORY_SEPARATOR, $paths[$os]); + if (!file_exists($path)) { + throw new ConfigException(sprintf('TON SDK library not found by path %s.', $paths[$os])); + } + return new self($path); } diff --git a/src/Composer/PostScript.php b/src/Composer/PostScript.php index 395f8bd..35cb1c4 100644 --- a/src/Composer/PostScript.php +++ b/src/Composer/PostScript.php @@ -76,7 +76,7 @@ public static function downloadLibrary(Event $event): void system($downloadScript); // Get or create bin dir - $binDir = $event->getComposer()->getConfig()->get('bin-dir'); + $binDir = str_replace('/', DIRECTORY_SEPARATOR, __DIR__ . '/../../bin/'); if (!file_exists($binDir) && !mkdir($binDir) && !is_dir($binDir)) { throw new RuntimeException(sprintf('Directory "%s" was not created', $binDir)); }