1 Star 0 Fork 0

UnPourTous/react-native-permissions

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
fetchWindowsCapabilites.js 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
// Fetch list of Windows UWP App capabilites from the Microsoft docs
// The names of individual capabilites are in <strong> tag and follow camelCase
const https = require('https');
const {EOL} = require('os');
https.get(
'https://docs.microsoft.com/en-us/windows/uwp/packaging/app-capability-declarations',
(res) => {
res.setEncoding('utf8');
let data = '';
res.on('error', ({message}) => {
console.error(message);
process.exit(-1);
});
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => parse(data));
},
);
function parse(data) {
const names = new Set();
for (const match of data.match(/<strong>[a-z]+[a-zA-Z\.]*<\/strong>/gm)) {
names.add(
match.substr('<strong>'.length, match.length - '<strong>'.length - '</strong>'.length),
);
}
const results = [];
for (const name of names) {
let constName = '';
for (let i = 0; i < name.length; ++i) {
const char = name.charAt(i);
if (char === char.toUpperCase()) {
constName += '_';
}
constName += char.toUpperCase();
}
constName = constName.replace('WI_FI', 'WIFI');
constName = constName.replace('VO_I_P', 'VOIP');
results.push(`${constName}: 'windows.permission.${name}',`);
}
console.log(results.sort().join(EOL));
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/UnPourTous/react-native-permissions.git
git@gitee.com:UnPourTous/react-native-permissions.git
UnPourTous
react-native-permissions
react-native-permissions
master

搜索帮助