make some code platform independent

This commit is contained in:
Balaji Krishnan 2017-03-15 17:31:52 -07:00
Родитель f66a9a0f3f
Коммит afd931f5f7
2 изменённых файлов: 3 добавлений и 2 удалений

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

@ -1,5 +1,6 @@
var fs = require('fs'); var fs = require('fs');
var path = require('path'); var path = require('path');
var os = require('os');
var vscode = require('vscode'); var vscode = require('vscode');
var codegen = require('../codegen/codgen.template-deploy'); var codegen = require('../codegen/codgen.template-deploy');
var jsonEditor = require('../codegen/jsoneditor'); var jsonEditor = require('../codegen/jsoneditor');
@ -66,7 +67,7 @@ function generateCodeInEditor() {
// insert code for template deployment. // insert code for template deployment.
const range = new vscode.Range(new vscode.Position(lineCount, 0), new vscode.Position(lineCount + 1, 0)); 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. // fix callsite to invoke the function that was newly generated.
const currentPos = new vscode.Position(vscode.window.activeTextEditor.selection.active.line, 0); const currentPos = new vscode.Position(vscode.window.activeTextEditor.selection.active.line, 0);

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

@ -111,7 +111,7 @@ function getSourceLocation() {
var files = vscode.workspace.textDocuments.filter(item => item.isUntitled === false); var files = vscode.workspace.textDocuments.filter(item => item.isUntitled === false);
if (files) { if (files) {
var sourceFile = files[0].fileName; var sourceFile = files[0].fileName;
return sourceFile.slice(0, sourceFile.lastIndexOf('\\') + 1); return sourceFile.slice(0, sourceFile.lastIndexOf(path.sep) + 1);
} }
} }