slight improvements to generated code

for template deployment.
This commit is contained in:
Balaji Krishnan 2017-03-13 16:40:21 -07:00
Родитель bd1e354e97
Коммит a665bf94ac
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -6,7 +6,6 @@ const deployTemplateFunctionName = 'deployTemplate';
exports.deployTemplate = function deployTemplate() { exports.deployTemplate = function deployTemplate() {
var text = `function ${deployTemplateFunctionName}(credentials, callback){\ var text = `function ${deployTemplateFunctionName}(credentials, callback){\
// TODO: initialize these variables // TODO: initialize these variables
var subscriptionId;\
var resourceGroupName;\ var resourceGroupName;\
var deploymentName;\ var deploymentName;\
var templateFilePath;\ var templateFilePath;\
@ -23,7 +22,7 @@ exports.deployTemplate = function deployTemplate() {
template = JSON.parse(fs.readFileSync(templateFilePath));\ template = JSON.parse(fs.readFileSync(templateFilePath));\
templateParameters = JSON.parse(fs.readFileSync(templateParametersFilePath));\ templateParameters = JSON.parse(fs.readFileSync(templateParametersFilePath));\
} catch (error) {\ } catch (error) {\
console.error('Encountered error parsing template file:', error);\ callback(error);\
}\ }\
\r\n \r\n
var resourceClient = new ResourceManagement.ResourceManagementClient(credentials, subscriptionId);\ var resourceClient = new ResourceManagement.ResourceManagementClient(credentials, subscriptionId);\
@ -39,7 +38,10 @@ exports.generateRequireStatements = function generateRequireStatements(document)
}; };
exports.deployTemplateCallSite = function deployTemplateCallSite() { exports.deployTemplateCallSite = function deployTemplateCallSite() {
var text = `${deployTemplateFunctionName}(credentials, function(err, result){ });`; var text = `${deployTemplateFunctionName}(credentials, function(err, result){\
if(err) return console.log(err);\
console.log('template deployed to azure!');\
});`;
return codegenerator.generateCode(text); return codegenerator.generateCode(text);
}; };