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

Commit

Permalink
improved caching in prompt plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed Jun 5, 2017
1 parent f5a4b73 commit 474c265
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Change Log (vs-deploy)

## 9.18.0 (June 5th, 2017; prompt target)
## 9.18.1 (June 5th, 2017; prompt target)

* added new [prompt](https://github.com/mkloubert/vs-deploy/wiki/target_prompt) target, which asks the user for a list of settings that will be applied to one or more other [targets](https://github.com/mkloubert/vs-deploy/wiki#targets-)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vs-deploy",
"displayName": "Deploy",
"description": "Commands for deploying files of your workspace to a destination.",
"version": "9.18.0",
"version": "9.18.1",
"publisher": "mkloubert",
"engines": {
"vscode": "^1.6.0"
Expand Down
18 changes: 16 additions & 2 deletions src/plugins/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class PromptPlugin extends deploy_objects.MultiFileDeployPluginBase {
wf.next((wfCtx) => {
wfCtx.value = {
properties: {},
propertiesToCache: [],
};
});

Expand Down Expand Up @@ -188,6 +189,7 @@ class PromptPlugin extends deploy_objects.MultiFileDeployPluginBase {
// create action
wf.next((wfCtx) => {
let properties = wfCtx.value['properties'];
let propertiesToCache: any[] = wfCtx.value['propertiesToCache'];

// define value converter
let valueConverter: (val: string) => any;
Expand Down Expand Up @@ -265,8 +267,10 @@ class PromptPlugin extends deploy_objects.MultiFileDeployPluginBase {
else {
if ('undefined' !== typeof userValue) {
if (doCache) {
me.context.targetCache()
.set(target, cacheKey, userValue);
propertiesToCache.push({
'key': cacheKey,
'value': userValue,
});
}

Promise.resolve( valueConverter(userValue) ).then((valueToSet) => {
Expand Down Expand Up @@ -452,6 +456,16 @@ class PromptPlugin extends deploy_objects.MultiFileDeployPluginBase {
await wfTargets.start();
});

// cache values
wf.next((wfCtx) => {
let propertiesToCache: any[] = wfCtx.value['propertiesToCache'];

propertiesToCache.forEach(ptc => {
me.context.targetCache()
.set(target, ptc.key, ptc.value);
});
});

wf.on('action.after',
afterWorkflowsAction);

Expand Down

0 comments on commit 474c265

Please sign in to comment.