Skip to content

Commit

Permalink
Add bin dir
Browse files Browse the repository at this point in the history
  • Loading branch information
maxvx committed Nov 15, 2020
1 parent 623b166 commit a15ced0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.idea/
vendor/
composer.lock
bin/tonclient.*
Empty file added bin/.gitkeep
Empty file.
14 changes: 9 additions & 5 deletions src/Binding/Binding.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Composer/PostScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit a15ced0

Please sign in to comment.