From afd931f5f7219de6944ee1f6f90cb5f503bd3fe8 Mon Sep 17 00:00:00 2001 From: Balaji Krishnan Date: Wed, 15 Mar 2017 17:31:52 -0700 Subject: [PATCH 1/3] make some code platform independent --- src/commands/azure-node.template-deploy.js | 3 ++- src/utils.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/commands/azure-node.template-deploy.js b/src/commands/azure-node.template-deploy.js index 9de17c4..50af957 100644 --- a/src/commands/azure-node.template-deploy.js +++ b/src/commands/azure-node.template-deploy.js @@ -1,5 +1,6 @@ var fs = require('fs'); var path = require('path'); +var os = require('os'); var vscode = require('vscode'); var codegen = require('../codegen/codgen.template-deploy'); var jsonEditor = require('../codegen/jsoneditor'); @@ -66,7 +67,7 @@ function generateCodeInEditor() { // insert code for template deployment. const range = new vscode.Range(new vscode.Position(lineCount, 0), new vscode.Position(lineCount + 1, 0)); - builder.replace(range, methodBody); + builder.replace(range, os.EOL + methodBody); // fix callsite to invoke the function that was newly generated. const currentPos = new vscode.Position(vscode.window.activeTextEditor.selection.active.line, 0); diff --git a/src/utils.js b/src/utils.js index 635b35b..bfc81a1 100644 --- a/src/utils.js +++ b/src/utils.js @@ -111,7 +111,7 @@ function getSourceLocation() { var files = vscode.workspace.textDocuments.filter(item => item.isUntitled === false); if (files) { var sourceFile = files[0].fileName; - return sourceFile.slice(0, sourceFile.lastIndexOf('\\') + 1); + return sourceFile.slice(0, sourceFile.lastIndexOf(path.sep) + 1); } } From b5fcfa0c3605f747316cbcbd946fea5e519b0020 Mon Sep 17 00:00:00 2001 From: Balaji Krishnan Date: Wed, 15 Mar 2017 23:15:01 -0700 Subject: [PATCH 2/3] Fix template deployment code --- src/codegen/codgen.template-deploy.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/codegen/codgen.template-deploy.js b/src/codegen/codgen.template-deploy.js index 1f84390..cddbbd9 100644 --- a/src/codegen/codgen.template-deploy.js +++ b/src/codegen/codgen.template-deploy.js @@ -12,11 +12,6 @@ exports.deployTemplate = function deployTemplate() { var templateParametersFilePath;\ var template;\ var templateParameters;\ - var parameters = {\ - template: template,\ - parameters: templateParameters,\ - mode: \'Complete\'\ - };\ \r\n try {\ template = JSON.parse(fs.readFileSync(templateFilePath));\ @@ -25,6 +20,17 @@ exports.deployTemplate = function deployTemplate() { callback(error);\ }\ \r\n + if (templateParameters.parameters)\ + templateParameters = templateParameters.parameters;\ + \r\n + var parameters = {\ + properties: {\ + template: template,\ + parameters: templateParameters,\ + mode: \'Complete\'\ + }\ + };\ + \r\n var resourceClient = new ResourceManagement.ResourceManagementClient(credentials, subscriptionId);\ resourceClient.deployments.createOrUpdate(resourceGroupName, deploymentName, parameters, callback);\ }`; From 538ca9303ed29867dfed27d0ac70d43eeab3b8d2 Mon Sep 17 00:00:00 2001 From: Balaji Krishnan Date: Wed, 15 Mar 2017 23:35:36 -0700 Subject: [PATCH 3/3] fix name generation for require statements --- src/codegen/codegen.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/codegen/codegen.js b/src/codegen/codegen.js index 66a4778..5fa4462 100644 --- a/src/codegen/codegen.js +++ b/src/codegen/codegen.js @@ -79,10 +79,14 @@ exports.getNameAssignmentForModule = function getNameAssignmentForModule(module) case 'ms-rest-azure': return 'msRestAzure'; default: - return; + return getDefaultName(module); } }; +function getDefaultName(module){ + return module.split('-').map(v => v.charAt(0).toUpperCase() + v.slice(1)).join(''); +} + exports.generateNewLine = function generateNewLine() { return this.generateCode('\r\n'); };