本文整理汇总了TypeScript中latest-version类的典型用法代码示例。如果您正苦于以下问题:TypeScript latest-version类的具体用法?TypeScript latest-version怎么用?TypeScript latest-version使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了latest-version类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: latestVersion
(async () => {
const current = pkg.version as string;
console.log("current:", current);
const latest = await latestVersion("mirakurun");
console.log("latest:", latest);
if (current === latest) {
console.log("already up to date.");
process.exit(0);
}
if (current.split(".")[0] !== latest.split(".")[0]) {
console.error("updater has aborted cause major version outdated.");
process.exit(0);
}
console.log("updating...");
const npm = spawnNpmInstall(latest);
npm.on("exit", (code) => {
if (code === 0) {
console.log("updated successfully.");
process.exit(0);
} else {
console.error("failed! reverting...");
const npm = spawnNpmInstall(current);
npm.on("exit", () => process.exit(1));
}
});
})();
开发者ID:upsilon,项目名称:Mirakurun,代码行数:31,代码来源:updater.ts
示例2: async
export const get: Operation = async (req, res) => {
const version: Version = {
current: pkg.version,
latest: await latestVersion("mirakurun")
};
api.responseJSON(res, version);
};
开发者ID:kanreisa,项目名称:Mirakurun,代码行数:9,代码来源:version.ts
示例3: async
export const put: Operation = async (req, res) => {
if (!req.query.force && !process.env.pm_uptime && !process.env.USING_WINSER) {
api.responseError(res, 500);
return;
}
const latest = await latestVersion("mirakurun");
if (!req.query.force && current === latest) {
api.responseError(res, 409, "Update Nothing");
return;
}
res.setHeader("Content-Type", "text/plain; charset=utf-8");
res.status(202);
res.write("Updating...\n");
const path = join(tmpdir(), "Mirakurun_Updating.log");
if (existsSync(path) === true) {
unlinkSync(path);
}
const out = openSync(path, "a");
const err = openSync(path, "a");
res.write(`> node lib/updater\n\n`);
const npm = spawn("node", ["lib/updater"], {
detached: true,
stdio: ["ignore", out, err]
});
npm.unref();
const tail = new Tail(path);
tail.on("line", data => res.write(data + "\n"));
req.once("close", () => {
tail.removeAllListeners("line");
tail.unwatch();
});
};
开发者ID:upsilon,项目名称:Mirakurun,代码行数:42,代码来源:update.ts
注:本文中的latest-version类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论