Skip to content

wrong message if you delete app's folder and run command with --path in it #4280

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

Closed
miroslavaivanova opened this issue Jan 10, 2019 · 4 comments · Fixed by #4538
Closed

wrong message if you delete app's folder and run command with --path in it #4280

miroslavaivanova opened this issue Jan 10, 2019 · 4 comments · Fixed by #4538

Comments

@miroslavaivanova
Copy link
Contributor

miroslavaivanova commented Jan 10, 2019

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.1.0
  • Android Runtime: 5.1.0
  • iOS Runtime: 5.1.0

Describe the bug
If you try to run app in non-project folder with --path in command without existing folder, you will see exception and you couldn't understand what is the problem.

To Reproduce

  1. tns create app
  2. navigate to folder different from app's folder
  3. run /folder/tns run ios --path app
  4. you will see message: Cannot read property 'targetedOS' of null

Expected behavior
correct error for non existing folder

@jamesgeorge007
Copy link
Contributor

jamesgeorge007 commented Apr 10, 2019

@miroslavaivanova @rosen-vladimirov I would like to take this up 👏 I'm new here and am not that aware of the code-base. It would be great if you could point me to the right files to work with 👍

@Fatme Fatme self-assigned this Apr 15, 2019
@Fatme
Copy link
Contributor

Fatme commented Apr 16, 2019

@jamesgeorge007,

Sorry for the late replay!

In order to implement this you need to change this line https://github.com/NativeScript/nativescript-cli/blob/master/lib/commands/run.ts#L69. $projectDataService should be injected here instead of $projectData.

$projectDataService: IProjectDataService

After that you need to change canExecute function here:

public async canExecute(args: string[]): Promise<boolean> {
    const projectData = this.$projectDataService.getProjectData();
}

After that you should change all occurrences of this.$projectData with projectData inside canExecute function.

As the this.$projectDataService.getProjectData() internally validates the path to the project, it''ll throw an error when the project path doesn't exist - https://github.com/NativeScript/nativescript-cli/blob/master/lib/project-data.ts#L93.

Feel free to write back if you need more information.

jamesgeorge007 added a commit to jamesgeorge007/nativescript-cli that referenced this issue Apr 16, 2019
Shows up an appropriate message while trying to run app in non-project directory
@ghost ghost added the new PR label Apr 16, 2019
@jamesgeorge007
Copy link
Contributor

@Fatme Kindly have a look at #4538 and let me know your suggestions 😃

@ghost ghost removed the new PR label Apr 16, 2019
@Fatme Fatme added this to the 5.4.0 milestone Apr 16, 2019
@Fatme
Copy link
Contributor

Fatme commented Apr 16, 2019

@jamesgeorge007,

Thank you for the contribution!

I merged your PR. If this is your first contribution to NativeScript, you are eligible for our NativeScript First-Time Contribution program. More info can be found here.

We'll be more than glad to help you, if you'd like to fix another bug or implement some feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment