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 May 29, 2017
·
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 |
---|---|
checkBeforeDeploy |
Check for newer files before a deployment starts or not. Default: (false)
|
options |
Optional value for the execution. |
script *
|
The script file to exeute. Default: ./deploy.js
|
* supports placeholders
A script file has the following skeleton (s. ScriptModule):
// this function is REQUIRED
exports.deployFile = function(args) {
if (args.canceled) {
return; // cancellation requested
}
// use this to tell the extension that
// we begin to deploy the file
args.onBeforeDeploy('Optional name of the destination, like a path or URL of the current file');
//TODO: deploy the file in
// 'args.file'
//
// check for 'args.canceled' == (true)
// in each of your "important" code parts
// where deployment can be cancelled
// return NOTHING to indicate that
// this is a SYNC execution
}
// this function is OPTIONAL
//
// by default the 'deployFile' is called for
// each file that is submitted to this function
exports.deployWorkspace = function(args) {
// you can return a Promise to
// indicate that this is
// an ASYNC execution
return new Promise(function(resolve, reject) {
try {
// iterate over the file list
// of 'args.files' property...
for (var fileIndex = 0; fileIndex < args.files.length; fileIndex++) {
if (args.canceled) {
// cancellation request
break;
}
var fileToDeploy = args.files[fileIndex];
try {
// use this to tell the extension that
// we begin to deploy the current file
args.onBeforeDeployFile(fileIndex);
//TODO: do the MAGIC here
//
// check for 'args.canceled' == (true)
// in each of your "important" code parts
// where deployment can be cancelled
// tell extension that a file operation
// has been completed
args.onFileCompleted(fileIndex);
}
catch (err) {
// tell that deployment of file failed
args.onFileCompleted(fileIndex, err);
}
}
resolve(); // no unhandled errors
}
catch (e) {
reject(e); // deployment failed
}
});
}
// [OPTIONAL]
// this is for the logic of
// PULLING A FILE --or--
// REQUEST FILE INFORMATION
//
// if not defined: deployFile() is used
exports.pullFile = function(args) {
// your code to pull file
// similar to 'deployFile()'
}
// [OPTIONAL]
// this is for the logic of
// PULLING FILES OF A PACKAGE
//
// if not defined: deployWorkspace() is used
exports.pullWorkspace = function(args) {
// your code to pull package
// similar to 'deployWorkspace()'
}