This repository was archived by the owner on Mar 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 389
Added hot reload and access log to console #183
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
31034c3
Merge pull request #1 from swooletw/develop
fractalzombie 0b89e1d
More code refactoring.
fractalzombie aed922f
More code refactoring.
fractalzombie ac0c514
Added access log to console.
fractalzombie a15cf16
Added some tests.
fractalzombie 83635cb
Fix for Carbon.
fractalzombie 01aa16c
Fix for array_sort.
fractalzombie 731fe95
Fix for array_sort.
fractalzombie a03b0ad
Fix for array_sort.
fractalzombie d803864
Added test for FSProcess
fractalzombie 7633221
Added test for FSProcess
fractalzombie 940f8dc
Added test for FSProcess
fractalzombie a0c1f86
Added locked check
fractalzombie e57125d
Fixed FSEventParser REGEX. I don't know why, but fswatch has two spaces
fractalzombie c50a714
Fixed FSEventParser REGEX. I don't know why, but fswatch has two spaces
fractalzombie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
More code refactoring.
Fix for OS Helper. Added Hot Reload with FSWatch.
- Loading branch information
commit aed922f141487cfe9dc084f098d81e5fe7fc1ac6
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| <?php | ||
|
|
||
| namespace SwooleTW\Http\HotReload; | ||
|
|
||
| use Illuminate\Support\Carbon; | ||
|
|
||
| /** | ||
| * Class FSEvent | ||
| */ | ||
| class FSEvent | ||
| { | ||
| /** | ||
| * Event - Created | ||
| * | ||
| * @var string | ||
| */ | ||
| public const Created = 'Created'; | ||
|
|
||
| /** | ||
| * Event - Updated | ||
| * | ||
| * @var string | ||
| */ | ||
| public const Updated = 'Updated'; | ||
|
|
||
| /** | ||
| * Event - Removed | ||
| * | ||
| * @var string | ||
| */ | ||
| public const Removed = 'Removed'; | ||
|
|
||
| /** | ||
| * Event - Renamed | ||
| * | ||
| * @var string | ||
| */ | ||
| public const Renamed = 'Renamed'; | ||
|
|
||
| /** | ||
| * Event - OwnerModified | ||
| * | ||
| * @var string | ||
| */ | ||
| public const OwnerModified = 'OwnerModified'; | ||
|
|
||
| /** | ||
| * Event - AttributeModified | ||
| * | ||
| * @var string | ||
| */ | ||
| public const AttributeModified = 'AttributeModified'; | ||
|
|
||
| /** | ||
| * Event - MovedFrom | ||
| * | ||
| * @var string | ||
| */ | ||
| public const MovedFrom = 'MovedFrom'; | ||
|
|
||
| /** | ||
| * Event - MovedTo | ||
| * | ||
| * @var string | ||
| */ | ||
| public const MovedTo = 'MovedTo'; | ||
|
|
||
| /** | ||
| * When event fired | ||
| * | ||
| * @var \Illuminate\Support\Carbon | ||
| */ | ||
| protected $when; | ||
|
|
||
| /** | ||
| * Directory or file path | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $path; | ||
|
|
||
| /** | ||
| * Event types | ||
| * | ||
| * @var array | ||
| */ | ||
| protected $types; | ||
|
|
||
| /** | ||
| * Event constructor. | ||
| * | ||
| * @param \Illuminate\Support\Carbon $when | ||
| * @param string $path | ||
| * @param array $types | ||
| */ | ||
| public function __construct(Carbon $when, string $path, array $types) | ||
| { | ||
| $this->when = $when; | ||
| $this->path = $path; | ||
| $this->types = $types; | ||
| } | ||
|
|
||
| /** | ||
| * @return \Illuminate\Support\Carbon | ||
| */ | ||
| public function getWhen(): Carbon | ||
| { | ||
| return $this->when; | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| public function getPath(): string | ||
| { | ||
| return $this->path; | ||
| } | ||
|
|
||
| /** | ||
| * @return array | ||
| */ | ||
| public function getTypes(): array | ||
| { | ||
| return $this->types; | ||
| } | ||
|
|
||
| /** | ||
| * Checks if event types has needed type(s) | ||
| * | ||
| * @param string ...$types | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function isType(string ...$types): bool | ||
| { | ||
| return count(array_intersect($this->types, $types)) > 0; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?php | ||
|
|
||
| namespace SwooleTW\Http\HotReload; | ||
|
|
||
| use Illuminate\Support\Carbon; | ||
|
|
||
| /** | ||
| * Class FSEventParser | ||
| */ | ||
| class FSEventParser | ||
| { | ||
| protected const REGEX = '/^([\S+]{3}\s+[\S+]{3}\s+[\d+]{2}\s+[\d+]{2}:[\d+]{2}:{0,2}:[\d+]{2}:{0,2}\s+[\d+]{0,4})\s+(\/[\S+]*)\s+([\S+*\s+]*)/mi'; | ||
|
|
||
| protected const DATE = 1; | ||
| protected const PATH = 2; | ||
| protected const EVENTS = 3; | ||
|
|
||
| /** | ||
| * @param string $event | ||
| * | ||
| * @return \SwooleTW\Http\HotReload\FSEvent | ||
| */ | ||
| public static function toEvent(string $event): ?FSEvent | ||
| { | ||
| if (preg_match(static::REGEX, $event, $matches)) { | ||
| $date = Carbon::parse($matches[static::DATE]); | ||
| $path = $matches[static::PATH]; | ||
| $events = explode(' ', $matches[static::EVENTS]); | ||
|
|
||
| return new FSEvent($date, $path, $events); | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found the reason that
FSEventParser::toEvent($event)is alwaysnullin my environment. I'm using OSX andfswatch 1.14.0. Here's what I received for the fswatch event:I haven't tested it on other platforms. But it works for my after changing the regex to:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @fractalzombie ,
Thank you so much ^^