Nativescript-cli: "tns debug {platform} --watch" inconvenient behavour

Created on 1 Dec 2016  路  6Comments  路  Source: NativeScript/nativescript-cli

tns debug ios --no-rebuild --watch doesn't build the app (as expected). If --no-rebuild argument is dropped still no build is triggered. In both cases if the app was not previously built (there is no app bundle in the platform's build directory) the command will fail with ENOENT: no such file or directory, scandir '/Users/buhov/Desktop/TheApp/platforms/ios/build/emulator.
This means that the command will always fail in a brand new or newly cloned application:

tns create MyApp
cd MyApp
tns debug ios --watch // This will fail. To make it work you have to run `tns build ios` first

Additionally, this command is run by the VSCode extension when the Sync on iOS/Android operation is triggered. In the extension we can "predict" whether the command will fail and trigger a build in such case, but this is a workaround. The real solution should be to trigger build in the CLI if the app hasn't been previously built. If triggering a build when --no-rebuild is explicitly set looks strange to someone, we can at least trigger a build on tns debug ios --watch. As a result the following scenario should not fail with error:

tns create MyApp
cd MyApp
tns debug ios --watch

Any ideas are welcome.

bug android ios

Most helpful comment

@Pip3r4o I also agree that --no-rebuild should be respected. Ideally tns debug ios/android --watch will trigger a build if needed and tns debug ios/android --no-rebuild --watch will never trigger a build.

All 6 comments

@ivanbuhov @Plamen5kov @rosen-vladimirov

Can we throw errors/output messages and terminate process when an app bundle is not available instead of implicitly triggering a build?

How do you think that would affect the user experience?

Currently some of the CLI commands and flag combinations act unpredictably, and that can cause frustration for the users. At the very least we can do is to write an elaborate list of all commands, valid flags for each, and expected behavior, along with listing of quirks, if any.

@Pip3r4o

Can we throw errors/output messages and terminate process when an app bundle is not available instead of implicitly triggering a build?

How do you think that would affect the user experience?

tns run ios/android will implicitly trigger a build when an app bundle is not available
tns deploy ios/android will implicitly trigger a build when an app bundle is not available
tns emulate ios/android will implicitly trigger a build when an app bundle is not available
tns livesync ios/android will implicitly trigger a build when an app bundle is not available
tns debug ios/android will implicitly trigger a build when an app bundle is not available
but
tns debug ios/android --watch fails with error message.
I find this behavour to be inconsistent and unexpected. I suggest implicitly triggering a build (if needed) even if the --watch flag is passed.

@ivanbuhov I agree on the above, I was referring more to the --no-rebuild (--rebuild false) flag, respect it when it's passed as-is

@Pip3r4o I also agree that --no-rebuild should be respected. Ideally tns debug ios/android --watch will trigger a build if needed and tns debug ios/android --no-rebuild --watch will never trigger a build.

Actually the current implementation of tns debug --watch behaves exactly as you described. It will trigger a new build implicitly when necessary. Maybe you used an old version? Could you confirm that?

After @tzraikov and I investigated the issue we found that tns debug {platform} --watch works as expected - it will rebuild the app only if needed. The error is caused by this issue: https://github.com/NativeScript/nativescript-cli/issues/2315 so I am closing this one.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

charsleysa picture charsleysa  路  3Comments

erjdriver picture erjdriver  路  3Comments

ZMW9 picture ZMW9  路  3Comments

trodellez picture trodellez  路  3Comments

bradmartin picture bradmartin  路  3Comments