-
-
Notifications
You must be signed in to change notification settings - Fork 197
Fix livesync/run issue #2508
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
Fix livesync/run issue #2508
Conversation
In case you try adding/removing directories in your `app` dir, `chokidar` (the file system watcher that we are using now instead of `gaze`) raises `addDir`/`unlinkDir` events. However we do not have handles for these events, so we do not execute anything. After that, when we add a file in the newly created dir, `chokidar` sends `add` event, we handle it and try to process the file. This works fine for iOS and Android devices, but it does not work at all for iOS Simulator, as we have not transferred the new directory to `platforms` dir. Add required handles for `addDir` and `unlinkDir` methods. Also currently there's a problem when already existing directory is renamed. In this case its modified time (`mtime`) is not changed, so the projectChangesService disregards the change and doesn't transfer it to `platforms` dir. After that, in case you modify any file inside the renamed dir, you'll see ENOENT error. In order to fix this, check the time of last status change (`ctime`) of the directory/file.
During `--watch`, when a change is detected, the project is prepared and after that we are trying to move the prepared file (from `platforms/<platform>/...` dir) to the device. However some plugins modify the content of the `platforms` directory on afterPrepare. For example `nativescript-dev-sass` allows you to use `.scss` files, on `beforePrepare` they are "transpiled" to `.css` files. After that, on `afterPrepare` the plugin itself removes the file from `platforms/<platform>/...` dir. CLI detects the change in `.scss` file, prepares the project (which moves the `.scss` file to `platforms` dir) and after that tries to move it from `platforms` to the device. During the last step, the `.scss` file is already removed from `platforms` directory, so our code fails. Meanwhile, the `beforePrepare` hook of the plugin has created/modified the `.css` file inside `app` dir. This will trigger new iteration, where the file will be sent to device. In order to fix the error when the `.scss` file is modified, we'll execute livesync only if the modified files exist in `platforms` dir.
run ci |
It looks with those changes we will not handle cases when user add new files, which is important case for getting started. All tutorials start with: |
@dtopuzov when user adds new file, it will be successfully synced to device. No changes in this behavior.
What happens before this PR when
Please note that step 3.1 will trigger additional iteration of the whole cycle, as the .css file is modified. |
@irman, we haven't published it yet, but it should be published by the end of the week. |
@Plamen5kov great to hear that. Can't wait. 😄 Thanks! |
is the package already available on npm? It seems to but I still having the same issue with nativescript-dev-sass. Thanks for your help |
@vincentpalita yes, 2.5.1 cli is published, and if you do a |
Ok I had to remove manually the version then install it back and it is now ... working :) That's great! |
Fix livesync when directories are modified
In case you try adding/removing directories in your
app
dir,chokidar
(the file system watcher that we are using now instead ofgaze
) raisesaddDir
/unlinkDir
events.However we do not have handles for these events, so we do not execute anything. After that, when we add a file in the newly created dir,
chokidar
sendsadd
event, we handle it and try to process the file.This works fine for iOS and Android devices, but it does not work at all for iOS Simulator, as we have not transferred the new directory to
platforms
dir.Add required handles for
addDir
andunlinkDir
methods.Also currently there's a problem when already existing directory is renamed. In this case its modified time (
mtime
) is not changed, so the projectChangesService disregards the change and doesn't transfer it toplatforms
dir. After that, in case you modify any file inside the renamed dir, you'll see ENOENT error. In order to fix this, check the time of last status change (ctime
) of the directory/file.LiveSync only existing files during
--watch
During
--watch
, when a change is detected, the project is prepared and after that we are trying to move the prepared file (fromplatforms/<platform>/...
dir) to the device.However some plugins modify the content of the
platforms
directory on afterPrepare. For examplenativescript-dev-sass
allows you to use.scss
files, onbeforePrepare
they are "transpiled" to.css
files.After that, on
afterPrepare
the plugin itself removes the file fromplatforms/<platform>/...
dir.CLI detects the change in
.scss
file, prepares the project (which moves the.scss
file toplatforms
dir) and after that tries to move it fromplatforms
to the device. During the last step, the.scss
file is already removed fromplatforms
directory, so our code fails.Meanwhile, the
beforePrepare
hook of the plugin has created/modified the.css
file insideapp
dir. This will trigger new iteration, where the file will be sent to device.In order to fix the error when the
.scss
file is modified, we'll execute livesync only if the modified files exist inplatforms
dir.Fixes #2476