Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Cannot save to globalStore #7

Closed
frigierim opened this issue Jan 23, 2019 · 4 comments
Closed

Cannot save to globalStore #7

frigierim opened this issue Jan 23, 2019 · 4 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@frigierim
Copy link

I am trying to save some state variable from a script, but this is not working:

exports.execute = async (args) => {
    await args.globalStore.set("current_platform", "test");
    var platform = args.globalStore.get("current_platform", "test failed");
    log(platform)
}

The platform variable always reports "test failed"; am I misinterpreting how this works?

@ghost
Copy link

ghost commented Jan 23, 2019

@frigierim

this seems to be correct ... can you try the following code (this works for me, when I register a button)?:

exports.execute = async (args) => {
    const vscode = args.require('vscode');

    await args.globalStore.set("current_platform", "test");
    var platform = args.globalStore.get("current_platform", "test failed");
    
    vscode.window.showInformationMessage(platform);
}

In what context do you use your script? Can you post a small example of your settings?

Can you also check the .store file in your ${HOME_DIR}/.vscode-powertools directory?

@frigierim
Copy link
Author

Thanks for the quick reply!
Your code is not working for me. I am using this when registering my button (in Workspace settings):

"ego.power-tools": {
	"commands": 
	{
		"select_platform" : 
		{
			"script": "commands\\ns-commands.js",
			"button": {
					"text": "Change platform",
					"tooltip": "Change build and deploy platform"
			}
		},
	}
}

but I still get "Test failed".
I don't have a .vscode-powertools directory, but the .store file is created (empty) in my .vscode/commands folder (i.e. the folder where the script I am running resides).

Could this layout be the reason for the failure?

@ghost
Copy link

ghost commented Jan 23, 2019

@frigierim

Yes, this is a bug ... try to create a .vscode-powertools sub folder inside your home directory and it should work.

@ghost ghost added bug Something isn't working good first issue Good for newcomers labels Jan 23, 2019
@frigierim
Copy link
Author

Lovely, it works!
Thank you.

ghost pushed a commit that referenced this issue Jan 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant