代码拉取完成,页面将自动刷新
const { logger } = require('appium-support');
const request = require('request');
const path = require('path');
const { createReadStream } = require('fs');
const log = logger.getLogger('CROWDIN');
const PROJECT_ID = process.env.CROWDIN_PROJECT_ID;
const PROJECT_KEY = process.env.CROWDIN_PROJECT_KEY;
if (!PROJECT_ID || !PROJECT_KEY) {
throw new Error(`Both CROWDIN_PROJECT_ID and CROWDIN_PROJECT_KEY environment ` +
`variables must be set`);
}
const resourcePath = path.resolve('assets', 'locales', 'en', 'translation.json');
const fieldName = `files[/${path.basename(resourcePath)}]`;
const options = {
url: `https://api.crowdin.com/api/project/${PROJECT_ID}/update-file?key=${PROJECT_KEY}`,
port: 443,
method: 'POST',
headers: {
'User-Agent': 'Appium Desktop',
},
formData: {
[fieldName]: createReadStream(resourcePath)
}
};
// eslint-disable-next-line promise/prefer-await-to-callbacks
request(options, (err, res, body) => {
if (err) {
throw err;
}
log.debug(`Response code: ${res.statusCode}`);
if (res.statusCode >= 400) {
throw new Error(JSON.stringify(body));
}
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。