1 Star 0 Fork 9

潘明越/pagic

forked from xcatliu/pagic 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mod.ts 1.69 KB
一键复制 编辑 原始数据 按行查看 历史
xcatliu 提交于 2020-09-09 13:49 . Finish i18n plugin
#!/usr/bin/env -S deno --unstable --allow-read --allow-write --allow-net
export { React, ReactDOM, ReactDOMServer } from './deps.ts';
export { t, Trans } from './src/plugins/i18n.tsx';
import Pagic from './src/Pagic.ts';
import { logger } from './src/utils/mod.ts';
export default Pagic;
export * from './src/Pagic.ts';
if (import.meta.main) {
const [subCommand, ...restArgs] = Deno.args;
if (subCommand === undefined) {
logger.info(` Miss valid subCommand, known as 'pagic build'.`);
Deno.exit(1);
}
const validSubCommands = ['build'];
if (!validSubCommands.includes(subCommand)) {
throw new Error(`Invalid subCommand ${subCommand}`);
}
const validOptions = ['serve', 'watch', 'port'];
let options: { [key: string]: any } = {};
for (let i = 0; i < restArgs.length; i++) {
const currentArg = restArgs[i];
const nextArg = restArgs[i + 1];
if (currentArg.startsWith('--')) {
const key = currentArg.slice(2);
if (!validOptions.includes(key)) {
throw new Error(`Invalid option ${key}`);
}
if (typeof nextArg === 'undefined' || nextArg.startsWith('-')) {
options[key] = true;
} else {
if (Number(nextArg).toString() === nextArg) {
options[key] = Number(nextArg);
} else {
options[key] = nextArg;
}
i++;
}
} else if (currentArg.startsWith('-')) {
const key = currentArg.slice(1);
if (!validOptions.includes(key)) {
throw new Error(`Invalid option ${key}`);
}
options[key] = true;
} else {
throw new Error(`Invalid args ${currentArg}`);
}
}
const pagic = new Pagic(options);
if (subCommand === 'build') {
pagic.build();
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/pan_mingyue/pagic.git
[email protected]:pan_mingyue/pagic.git
pan_mingyue
pagic
pagic
master

搜索帮助