1 Star 0 Fork 0

望日蓮/appium-desktop

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
crowdin-update-resources.js 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
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));
}
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wgqcd/appium-desktop.git
git@gitee.com:wgqcd/appium-desktop.git
wgqcd
appium-desktop
appium-desktop
master

搜索帮助