This repository has been archived by the owner on Jul 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
target_script
Marcel Kloubert edited this page Dec 18, 2016
·
50 revisions
Deploys via a JS script.
{
"deploy": {
"targets": [
{
"type": "script",
"name": "My script",
"description": "A deploy script",
"script": "E:/test/deploy.js",
"options": {
"TM": 5979,
"MK": "23979"
}
}
]
}
}
Name | Description |
---|---|
options |
Optional value for the execution. |
script |
The script file to exeute. Default: ./deploy.js
|
A script file has the following skeleton (s. ScriptModule):
// this function is REQUIRED
function deployFile(args) {
return new Promise(function(resolve, reject) {
// tell extension that whole operation
// has been completed
var onCompleted = function(err, canceled) {
args.canceled = canceled;
if (err) {
reject(err);
}
else {
resolve(args); // send input arguments
// back to the extension
}
};
if (args.context.isCancelling()) {
onCompleted(null, true); // cancellation request
return;
}
// use this to tell the extension that
// we begin to deploy the file
var onBeforeDeploy = function() {
if (args.deployOptions.onBeforeDeploy) {
args.deployOptions.onBeforeDeploy(args.sender, {
file: args.file,
target: args.target
});
}
};
try {
onBeforeDeploy();
//TODO: do the MAGIC here
onCompleted();
}
catch (e) {
onCompleted(e);
}
});
}
exports.deployFile = deployFile;
// this function is OPTIONAL
//
// by default the 'deployFile' is called for
// each file that is submitted to this function
function deployWorkspace(args) {
return new Promise(function(resolve, reject) {
// tell extension that whole operation
// has been completed
var onCompleted = function(err, canceled) {
args.canceled = canceled;
if (err) {
reject(err);
}
else {
resolve(args); // send input arguments
// back to the extension
}
};
// use this to tell the extension that
// we begin to deploy a file
// from the
var onBeforeDeployFile = function(fileToDeploy) {
if (args.deployOptions.onBeforeDeployFile) {
args.deployOptions.onBeforeDeployFile(args.sender, {
file: fileToDeploy,
target: args.target
});
}
};
// tell extension that a file operation
// has been completed
var onFileCompleted = function(deployedFile, err) {
if (args.deployOptions.onFileCompleted) {
args.deployOptions.onFileCompleted(args.sender, {
error: err,
file: deployedFile,
target: args.target
});
}
};
try {
// iterate over the file list
// of 'args.files' property...
for (var i = 0; i < args.files.length; i++) {
if (args.context.isCancelling()) {
onCompleted(null, true); // cancellation request
return;
}
var fileToDeploy = args.files[i];
try {
onBeforeDeployFile(fileToDeploy);
//TODO: do the MAGIC here
onFileCompleted(fileToDeploy);
}
catch (e) {
onFileCompleted(fileToDeploy, e);
}
}
onCompleted();
}
catch (e) {
onCompleted(e);
}
});
}
exports.deployWorkspace = deployWorkspace;