-
-
Notifications
You must be signed in to change notification settings - Fork 197
Fix multiple typescript/sass watchers #3332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -527,7 +527,7 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi | |||
|
|||
const currentWatcherInfo = this.liveSyncProcessesInfo[liveSyncData.projectDir].watcherInfo; | |||
|
|||
if (!currentWatcherInfo || currentWatcherInfo.pattern !== pattern) { | |||
if (!currentWatcherInfo || currentWatcherInfo.pattern.toString() !== pattern.toString()) { |
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.
It might be good to sort the array (if its an array) so that the order of patterns doesn't matter.
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.
Actually, pattern
is always an array as it can be seen here. currentWatcherInfo.pattern
on the other hand is always an array too as it is actually the same pattern
.
So there is no need to sort the array, as both arrays always have the same order.
@KristianDD what do you think?
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.
@Mitko-Kerezov But as seen here it can be a string. And as I will add configurations for livesync the patterns might change.
f553e9c
to
a6165ec
Compare
Ping @KristianDD and @rosen-vladimirov. In light of @KristianDD's suggestion I decided to take a different approach to this. |
Whenever using CLI as a library, calling livesync multiple times leads to multiple typescript/sass watchers. This happens due to the fact that `currentWatcherInfo.pattern` is an array and checking two arrays for equality with `!==` is bound to return `true` at all times. `toString()` both arrays and check the string literals instead.
a6165ec
to
3f01716
Compare
@@ -526,8 +526,8 @@ export class LiveSyncService extends EventEmitter implements IDebugLiveSyncServi | |||
} | |||
|
|||
const currentWatcherInfo = this.liveSyncProcessesInfo[liveSyncData.projectDir].watcherInfo; | |||
|
|||
if (!currentWatcherInfo || currentWatcherInfo.pattern !== pattern) { | |||
const areWatcherPatternsDifferent = () => _.difference(currentWatcherInfo.pattern, pattern).length || _.difference(pattern, currentWatcherInfo.pattern).length; |
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.
You might use _.xor(currentWatcherInfo.pattern, pattern).length
(not sure, should be checked).
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.
Was looking for this, thanks!
lib/definitions/livesync.d.ts
Outdated
@@ -60,7 +60,7 @@ interface ILiveSyncProcessInfo { | |||
timer: NodeJS.Timer; | |||
watcherInfo: { | |||
watcher: IFSWatcher, | |||
pattern: string | string[] | |||
pattern: string[] |
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.
Optional: would look better if the property is called patterns
.
Whenever using CLI as a library, calling livesync multiple times leads to multiple typescript/sass watchers.
This happens due to the fact that
currentWatcherInfo.pattern
is an array and checking two arrays for equality with!==
is bound to returntrue
at all times.toString()
both arrays and check the string literals instead.Ping @KristianDD @rosen-vladimirov