telerik / mobile-cli-lib

Contains common infrastructure for CLIs - mainly AppBuilder, NativeScript, DDB and Proton.
Apache License 2.0
11 stars 10 forks source link

Use profileDir from settingsService #1023

Closed rosen-vladimirov closed 6 years ago

rosen-vladimirov commented 6 years ago

Currently CLI's configuration directory is used from $options.profileDir. When user passes --profileDir <path>, the $options.profileDir value is populated. In case user does not pass anything, a default value is set. All services that require configuration directory use the $options.profileDir. However, this causes several issues:

In order to resolve these issues, move the logic for profileDir in settingsService and introduce a new method to get the profileDir. In order to ensure code is backwards compatible (i.e. extensions that use $options.profileDir should still work), modify $options to set the value of profileDir in settingsService. Whenever you want to test local extensions you can use:

const tns = require("nativescript");
tns.settingsService.setSettings({ profileDir: "my custom dir" });
Promise.all(tns.extensibilityService.loadExtensions())
    .then((result) => {
        console.log("Loaded extensions:", result);
        // write your code here
    });

Replace all places where $options.profileDir is used with $settingsService.getProfileDir().