Skip to content

Commit

Permalink
Option to disable ssl verification added
Browse files Browse the repository at this point in the history
  • Loading branch information
ky-one committed May 19, 2018
1 parent 036fcf3 commit 0b51df4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ky-generator",
"displayName": "KY-Generator",
"description": "Visual Studio Code Extension for KY.Generator",
"version": "1.0.2",
"version": "1.0.3",
"publisher": "KY-Programming",
"icon": "images/128.png",
"repository": "https://github.com/KY-Programming/generator-vs-code",
Expand All @@ -29,7 +29,8 @@
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "npm run compile && node ./node_modules/vscode/bin/test"
"test": "npm run compile && node ./node_modules/vscode/bin/test",
"publish": "vsce publish"
},
"devDependencies": {
"typescript": "^2.6.1",
Expand Down
19 changes: 13 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,29 @@ export function activate(context: vscode.ExtensionContext) {
const file = files[0];
vscode.workspace.openTextDocument(file.fsPath).then(result => {
const content = result.getText();
debugger;
let url: string;
let strictSSL: boolean;
if (content[0] === '{') {
const configuration = JSON.parse(content);
url = configuration.Generator.Connection;
strictSSL = configuration.Generator.VerifySsl;
}
else {
const start = content.indexOf('<Generator>') + 11;
const end = content.indexOf('</Generator>');
const generatorNode = content.substring(start, end);
const connectionStart = generatorNode.indexOf('<Connection>') + 12;
const connectionEnd = generatorNode.indexOf('</Connection>');
const connectionEnd = generatorNode.indexOf('</Connection>');
url = generatorNode.substring(connectionStart, connectionEnd).trim();
const verifySslStart = generatorNode.indexOf('<VerifySsl>') + 11;
const verifySslEnd = generatorNode.indexOf('</VerifySsl>');
strictSSL = verifySslEnd === -1 || generatorNode.substring(verifySslStart, verifySslEnd).trim() !== 'false';
}
if (strictSSL === false) {
process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;
}
let id: string;
http.post(url + '/Create', { configuration: content })
http.post(url + '/Create', { configuration: content, })
.then((response: any) => {
id = response.data;
return http.get(url + '/GetFiles/' + id);
Expand All @@ -76,10 +83,10 @@ export function activate(context: vscode.ExtensionContext) {
});
promises.push(promise);
});
return Promise.all(promises);
return Promise.all(promises).then(() => filePaths.length);
})
.then(() => {
vscode.window.showInformationMessage('Done');
.then((count: number) => {
vscode.window.showInformationMessage(count + ' files generated');
})
.catch((error: Error) => {
vscode.window.showErrorMessage('Can not reach the generator server #231d\r\n' + error);
Expand Down

0 comments on commit 0b51df4

Please sign in to comment.