Switched to HTTPS requests for Transifex. Added check for empty keys in .nls.json when preparing XLFs
This commit is contained in:
Родитель
f9c73ca3c0
Коммит
b01169cdb7
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "vscode-nls-dev",
|
||||
"version": "2.1.2",
|
||||
"version": "2.1.3",
|
||||
"description": "Development time npm module to generate strings bundles from Javascript files",
|
||||
"author": "Microsoft Corporation",
|
||||
"license": "MIT",
|
||||
|
|
17
src/main.ts
17
src/main.ts
|
@ -13,7 +13,7 @@ import { ThroughStream } from 'through';
|
|||
import * as Is from 'is';
|
||||
import * as xml2js from 'xml2js';
|
||||
import * as glob from 'glob';
|
||||
import * as http from 'http';
|
||||
import * as https from 'https';
|
||||
|
||||
var util = require('gulp-util');
|
||||
var iconv = require('iconv-lite');
|
||||
|
@ -456,9 +456,10 @@ function importModuleOrPackageJson(file: File, json: ModuleJsonFormat | PackageJ
|
|||
let extension = extensions[extensionName] ?
|
||||
extensions[extensionName] : extensions[extensionName] = { xlf: new XLF(projectName), processed: 0 };
|
||||
|
||||
if (ModuleJsonFormat.is(json)) {
|
||||
extension.xlf.addFile(originalFilePath, json['keys'], json['messages']);
|
||||
} else {
|
||||
// .nls.json can come with empty array of keys and messages, check for it
|
||||
if (ModuleJsonFormat.is(json) && json.keys.length !== 0) {
|
||||
extension.xlf.addFile(originalFilePath, json.keys, json.messages);
|
||||
} else if (PackageJsonFormat.is(json) && Object.keys(json).length !== 0) {
|
||||
extension.xlf.addFile(originalFilePath, Object.keys(json), messages);
|
||||
}
|
||||
|
||||
|
@ -511,7 +512,7 @@ function tryGetResource(project: string, slug: string, apiHostname: string, cred
|
|||
method: 'GET'
|
||||
};
|
||||
|
||||
const request = http.request(options, (response) => {
|
||||
const request = https.request(options, (response) => {
|
||||
if (response.statusCode === 404) {
|
||||
resolve(false);
|
||||
} else if (response.statusCode === 200) {
|
||||
|
@ -547,7 +548,7 @@ function createResource(project: string, slug: string, xlfFile: File, apiHostnam
|
|||
method: 'POST'
|
||||
};
|
||||
|
||||
let request = http.request(options, (res) => {
|
||||
let request = https.request(options, (res) => {
|
||||
if (res.statusCode === 201) {
|
||||
log(`Resource ${project}/${slug} successfully created on Transifex.`);
|
||||
} else {
|
||||
|
@ -581,7 +582,7 @@ function updateResource(project: string, slug: string, xlfFile: File, apiHostnam
|
|||
method: 'PUT'
|
||||
};
|
||||
|
||||
let request = http.request(options, (res) => {
|
||||
let request = https.request(options, (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
res.setEncoding('utf8');
|
||||
|
||||
|
@ -652,7 +653,7 @@ function retrieveResource(language: string, resource: Resource, apiHostname, cre
|
|||
method: 'GET'
|
||||
};
|
||||
|
||||
let request = http.request(options, (res) => {
|
||||
let request = https.request(options, (res) => {
|
||||
let xlfBuffer: Buffer[] = [];
|
||||
res.on('data', (chunk) => xlfBuffer.push(<Buffer>chunk));
|
||||
res.on('end', () => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче