Skip to content

Commit 39120ac

Browse files
authored
Update Moonlight.php (#7)
1 parent 7405284 commit 39120ac

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Moonlight.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ protected static function copyFiles(array $files, bool $force = false)
186186
*/
187187
protected static function ensureFileDirectoryExists(string $file)
188188
{
189-
if (! $directory = Str::beforeLast($file, '/')) {
189+
if (! $directory = static::getFileDirectory($file)) {
190190
return;
191191
}
192192

@@ -195,6 +195,19 @@ protected static function ensureFileDirectoryExists(string $file)
195195
}
196196
}
197197

198+
/**
199+
* Get directory of the given file.
200+
*
201+
* @param string $file
202+
* @return string|null
203+
*/
204+
protected static function getFileDirectory(string $file)
205+
{
206+
if (Str::contains($file, '/')) {
207+
return Str::beforeLast($file, '/')
208+
}
209+
}
210+
198211
/**
199212
* Confirm the replacement of a given file.
200213
*

0 commit comments

Comments
 (0)