Separate download and clean up script
This commit is contained in:
parent
badf79e134
commit
211b380cfa
13 changed files with 103 additions and 91 deletions
|
|
@ -5,7 +5,6 @@
|
|||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var https = require('https');
|
||||
var AdmZip = require('adm-zip');
|
||||
var bhttp = require('bhttp');
|
||||
|
||||
var crowdin_identifier = 'copay'
|
||||
|
|
@ -20,7 +19,7 @@ var local_file_name3 = path.join(__dirname, 'docs/updateinfo_en.txt')
|
|||
var local_file3 = fs.createReadStream(local_file_name3)
|
||||
|
||||
// obtain the crowdin api key
|
||||
var crowdin_api_key = fs.readFileSync(path.join(__dirname, 'crowdin_api_key.txt')).slice(3) //slicing utf-8 BOM
|
||||
var crowdin_api_key = fs.readFileSync(path.join(__dirname, 'crowdin_api_key.txt'))
|
||||
//console.log('api key: ' + crowdin_api_key);
|
||||
|
||||
if (crowdin_api_key != '') {
|
||||
|
|
@ -41,27 +40,5 @@ if (crowdin_api_key != '') {
|
|||
console.log('Export Got error: ' + e.message);
|
||||
});
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Download most recent translations for all languages.
|
||||
https.get('https://crowdin.com/download/project/' + crowdin_identifier + '.zip', function(res) {
|
||||
var data = [], dataLen = 0;
|
||||
|
||||
res.on('data', function(chunk) {
|
||||
data.push(chunk);
|
||||
dataLen += chunk.length;
|
||||
}).on('end', function() {
|
||||
var buf = new Buffer(dataLen);
|
||||
for (var i=0, len = data.length, pos = 0; i < len; i++) {
|
||||
data[i].copy(buf, pos);
|
||||
pos += data[i].length;
|
||||
};
|
||||
var zip = new AdmZip(buf);
|
||||
zip.extractAllTo('./', true);
|
||||
console.log('Done extracting ZIP file.');
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue