當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript latest-version類代碼示例

本文整理匯總了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;未經允許,請勿轉載。