Skip to content

Fix infinite loop of tns run #6

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

Merged
merged 1 commit into from
Aug 14, 2017
Merged

Fix infinite loop of tns run #6

merged 1 commit into from
Aug 14, 2017

Conversation

rosen-vladimirov
Copy link
Contributor

@rosen-vladimirov rosen-vladimirov commented Aug 10, 2017

When you have devices with different platorm, since NativeScript CLI 3.1.3, you can use tns run command to run your app simultaneously on all devices.
However, when a change is applied, CLI prepares the project for the first platform (for example iOS) and syncs it to all available iOS devices and simulators.
After that, the project is prepared for the other platform (Android in this case) and syncs the changes to all available Android devices and emulators.
The first prepare (for iOS) will parse all .less files and will create .css files for each of them.
The second prepare (for Android) will do the same and will rewrite the files. At this point CLI is watching for file changes and will detect the new .css files (they have the same content, but they are newly created files, as the plugin is always writing) and will trigger new prepare steps.
And this continues indefinetely.
In order to fix it, check the content of the output.css file with the current content of the file and if they are the same, do not overwrite the file.
This way the first prepare (for iOS) will create all .css files, the prepare for Android will not overwrite them and CLI will not go into infinite loop.

Fixes NativeScript/nativescript-cli#3017

When you have devices with different platorm, since NativeScript CLI 3.1.3, you can use `tns run` command to run your app simultaneously on all devices.
However, when a change is applied, CLI prepares the project for the first platform (for example iOS) and syncs it to all available iOS devices and simulators.
After that, the project is prepared for the other platform (Android in this case) and syncs the changes to all available Android devices and emulators.
The first prepare (for iOS) will parse all `.less` files and will create `.css` files for each of them.
The second prepare (for Android) will do the same and will rewrite the files. At this point CLI is watching for file changes and will detect the new `.css` files (they have the same content, but they are newly created files, as the plugin is always writing) and will trigger new prepare steps.
And this continues indefinetely.
In order to fix it, check the content of the output.css file with the current content of the file and if they are the same, do not overwrite the file.
This way the first prepare (for iOS) will create all `.css` files, the prepare for Android will not overwrite them and CLI will not go into infinite loop.
@rosen-vladimirov rosen-vladimirov self-assigned this Aug 10, 2017
@radeva radeva merged commit 0829626 into master Aug 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TNS run endless deployment loop
3 participants