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

Commit

Permalink
added startBuildTask setting
Browse files Browse the repository at this point in the history
  • Loading branch information
mkloubert committed May 29, 2017
1 parent 50eb234 commit 88fa327
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Change Log (vs-deploy)

## 9.11.0 (May 29th, 2017; settings)
## 9.11.0 (May 29th, 2017; settings and placeholders)

* added `alwaysShowPackageList` setting that indicates if package list is shown, even if there is only 1 entry
* added `alwaysShowTargetList` setting that indicates if target list is shown, even if there is only 1 entry
* added `username` and `password` settings for [HTTP target operations](https://github.com/mkloubert/vs-deploy/wiki/targetoperations#http-)
* added build-in [placeholders](https://github.com/mkloubert/vs-deploy/wiki/values) `EOL`, `hostName` and `tempDir`
* added `startBuildTask` that can defines if `workbench.action.tasks.build` (build task) should be run on startup or not

## 9.10.0 (May 28th, 2017; new list target)

Expand Down
14 changes: 14 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,20 @@
"description": "Starts the REST API or not (s. https://github.com/mkloubert/vs-rest-api).",
"default": false
},
"startBuildTask": {
"oneOf": [
{
"type": "boolean",
"description": "Indicates if build task should be run on startup or not.",
"default": "false"
},
{
"type": "integer",
"description": "Defines the number of milliseconds to wait before the build task is run.",
"minimum": 0
}
]
},
"startCronJobs": {
"type": "boolean",
"description": "Starts the cron jobs or not (s. https://github.com/mkloubert/vs-cron).",
Expand Down
55 changes: 55 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import * as vscode from 'vscode';
import * as Workflows from 'node-workflows';


let buildTaskTime: NodeJS.Timer;

/**
* Returns a merged config object.
*
Expand Down Expand Up @@ -232,3 +234,56 @@ export function mergeConfig(cfg: deploy_contracts.DeployConfiguration): Promise<
}
});
}

/**
* Runs the build task, if defined in config.
*/
export function runBuildTask() {
let me: vs_deploy.Deployer = this;
let cfg = me.config;

// close old timer (if defined)
try {
let btt = buildTaskTime;
if (btt) {
clearTimeout(btt);
}
}
catch (e) {
me.log(i18.t('errors.withCategory',
'config.runBuildTask(1)', e));
}
finally {
buildTaskTime = null;
}

let doRun = false;
let timeToWait: number;
if (!deploy_helpers.isNullOrUndefined(cfg.startBuildTask)) {
if ('boolean' === typeof cfg.startBuildTask) {
doRun = cfg.startBuildTask;
}
else {
timeToWait = parseInt(deploy_helpers.toStringSafe(cfg.startBuildTask));
}
}

let executeBuildTaskCommand = () => {
vscode.commands.executeCommand('workbench.action.tasks.build').then(() => {
}, (err) => {
me.log(i18.t('errors.withCategory',
'config.runBuildTask(2)', err));
});
};

if (doRun) {
if (isNaN(timeToWait)) {
executeBuildTaskCommand();
}
else {
buildTaskTime = setTimeout(() => {
executeBuildTaskCommand();
}, timeToWait);
}
}
}
5 changes: 5 additions & 0 deletions src/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,11 @@ export interface DeployConfiguration extends vscode.WorkspaceConfiguration {
* s. https://github.com/mkloubert/vs-rest-api
*/
startApi?: boolean;
/**
* Run build task on startup or define the wait time, in milliseconds, after
* the build task should be run after startup.
*/
startBuildTask?: boolean | number;
/**
* Starts the cron jobs or not.
* s. https://github.com/mkloubert/vs-cron
Expand Down
3 changes: 3 additions & 0 deletions src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3964,6 +3964,9 @@ export class Deployer extends Events.EventEmitter implements vscode.Disposable {
}
}

deploy_config.runBuildTask
.apply(me);

if (showDefaultTemplateRepos) {
// check official repo version
deploy_templates.checkOfficialRepositoryVersions
Expand Down

0 comments on commit 88fa327

Please sign in to comment.