crowdin-api
Advanced tools
Comparing version 2.0.0 to 2.0.1
38
index.js
@@ -51,2 +51,6 @@ 'use strict'; | ||
const out = fs.createWriteStream(null, { | ||
fd | ||
}); | ||
return new Bluebird((resolve, reject) => { | ||
@@ -57,3 +61,3 @@ let statusCode; | ||
.on('error', err => { | ||
reject(parseError(err)); | ||
return reject(parseError(err)); | ||
}) | ||
@@ -63,18 +67,28 @@ .on('response', response => { | ||
}) | ||
.on('close', async () => { | ||
if (statusCode < 400) { | ||
resolve(path); | ||
} else { | ||
.pipe(out); | ||
out.on('close', async () => { | ||
if (statusCode < 400) { | ||
return resolve(path); | ||
} else { | ||
try { | ||
let body = await Bluebird.fromCallback(cb => fs.readFile(path, { | ||
encoding: 'utf8' | ||
}, cb)); | ||
try { | ||
const result = await Bluebird.fromCallback(cb => fs.readFile(path, 'utf8')); | ||
const result = JSON.parse(body); | ||
reject(resultToError(result)); | ||
return reject(resultToError(result)); | ||
} catch (err) { | ||
reject(`Error streaming from Crowdin: ${statusCode}`); | ||
console.log('Error parsing body', err); | ||
console.log(body); | ||
} | ||
} catch (err) { | ||
console.log('Error reading body file', err); | ||
} | ||
}) | ||
.pipe(fs.createWriteStream(null, { | ||
fd | ||
})); | ||
return reject(`Error streaming from Crowdin: ${statusCode}`); | ||
} | ||
}); | ||
}); | ||
@@ -81,0 +95,0 @@ } |
{ | ||
"name": "crowdin-api", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "API client for Crowdin", | ||
@@ -5,0 +5,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12867
293
0