本文整理汇总了TypeScript中common/Logger.child函数的典型用法代码示例。如果您正苦于以下问题:TypeScript child函数的具体用法?TypeScript child怎么用?TypeScript child使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了child函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
sanityCheck: async (versionPrefix: string) => {
await spawn({
ctx: new MinimalContext(),
logger: rootLogger.child({ name: "itch-setup formula" }),
command: ospath.join(versionPrefix, "itch-setup"),
args: ["--version"],
});
},
示例2: function
import { Watcher } from "common/util/watcher";
import { actions } from "common/actions";
import rootLogger from "common/logger";
const logger = rootLogger.child({ name: "abort-task" });
import { getCurrentTasks } from "./as-task-persistent-state";
export default function(watcher: Watcher) {
watcher.on(actions.abortTask, async (store, action) => {
const { id } = action.payload;
const ctx = getCurrentTasks()[id];
if (ctx) {
try {
await ctx.tryAbort();
} catch (e) {
logger.warn(`Could not cancel task ${id}: ${e.stack}`);
}
}
});
}
示例3: function
import { Watcher } from "common/util/watcher";
import { actions } from "common/actions";
import fs from "fs";
import { dirname } from "path";
import rootLogger from "common/logger";
const logger = rootLogger.child({ name: "explore-cave" });
import * as explorer from "../../os/explorer";
import { withLogger, messages } from "common/butlerd";
const call = withLogger(logger);
export default function(watcher: Watcher) {
watcher.on(actions.exploreCave, async (store, action) => {
const { caveId } = action.payload;
const { cave } = await call(messages.FetchCave, { caveId });
const installFolder = cave.installInfo.installFolder;
try {
fs.accessSync(installFolder);
explorer.open(installFolder);
} catch (e) {
explorer.open(dirname(installFolder));
}
});
}
示例4: function
import { Watcher } from "common/util/watcher";
import { actions } from "common/actions";
import rootLogger from "common/logger";
const logger = rootLogger.child({ name: "queue-cave-uninstall" });
import { promisedModal } from "../modals";
import asTask from "./as-task";
import { modalWidgets } from "renderer/components/modal-widgets/index";
import { performUninstall } from "../downloads/perform-uninstall";
import { withLogger, messages } from "common/butlerd";
const call = withLogger(logger);
export default function(watcher: Watcher) {
watcher.on(actions.queueCaveUninstall, async (store, action) => {
const { caveId } = action.payload;
// TODO: figure if we really need that. asTask wants a gameId
// but do we really need it? how used is asTask anyway?
const { cave } = await call(messages.FetchCave, { caveId });
await asTask({
name: "uninstall",
gameId: cave.game.id,
store,
work: async (ctx, logger) => {
await performUninstall(logger, caveId);
store.dispatch(actions.uninstallEnded({}));
示例5: function
import { Watcher } from "common/util/watcher";
import { actions } from "common/actions";
import rootLogger, { Logger } from "common/logger";
const logger = rootLogger.child({ name: "queue-game" });
import asTask from "./as-task";
import { IStore } from "common/types/index";
import { Game, Upload, Build } from "common/butlerd/messages";
import { map, isEmpty } from "underscore";
import { modalWidgets } from "renderer/components/modal-widgets/index";
import { withLogger, messages } from "common/butlerd";
const call = withLogger(logger);
import { promisedModal } from "../modals";
import { makeInstallErrorModal } from "./make-install-error-modal";
import { makeUploadButton } from "main/reactors/make-upload-button";
export default function(watcher: Watcher) {
watcher.on(actions.queueGame, async (store, action) => {
const { game } = action.payload;
const { caves } = await call(messages.FetchCavesByGameID, {
gameId: game.id,
});
if (isEmpty(caves)) {
logger.info(
`No cave for ${game.title} (#${game.id}), attempting install`
示例6: updateCommonsNow
import { Watcher } from "common/util/watcher";
import { IStore } from "common/types";
import { indexBy, isEmpty } from "underscore";
import groupIdBy from "common/helpers/group-id-by";
import { actions } from "common/actions";
import { throttle, isEqual } from "underscore";
import rootLogger from "common/logger";
import { messages, withLogger } from "common/butlerd";
const logger = rootLogger.child({ name: "commons" });
const call = withLogger(logger);
async function updateCommonsNow(store: IStore) {
try {
await updateCommonsNowThrows(store);
} catch (e) {
logger.warn(`While fetching commons: ${e.stack}`);
}
}
async function updateCommonsNowThrows(store: IStore) {
if (!store.getState().setup.done) {
return;
}
const { caves, downloadKeys, installLocations } = await call(
messages.FetchCommons,
{}
);
示例7: resolve
import { resolve, join, basename } from "path";
import { app } from "electron";
import spawn from "../spawn";
import * as sf from "../sf";
import { MinimalContext } from "../../context";
import rootLogger, { devNull } from "common/logger";
const logger = rootLogger.child({ name: "shortcut" });
const appFolder = resolve(process.execPath, "..");
const rootFolder = resolve(appFolder, "..");
export const updateExePath = join(rootFolder, "Update.exe");
const exeName = basename(process.execPath);
export async function updateRun(
ctx: MinimalContext,
args: string[]
): Promise<void> {
logger.info(`Update.exe located at = ${updateExePath}`);
try {
await spawn.assert({
command: updateExePath,
args,
ctx,
logger: devNull,
});
} catch (err) {
logger.error(`Running Update failed with ${err.message}`);
}
}
示例8:
import { screen } from "electron";
import { createSelector } from "reselect";
import { format as formatUrl, UrlObject } from "url";
import * as path from "path";
import env from "common/env";
import { darkMineShaft } from "common/constants/colors";
import { app, BrowserWindow, BrowserWindowConstructorOptions } from "electron";
import config from "common/util/config";
import * as os from "../os";
import { debounce } from "underscore";
import rootLogger from "common/logger";
const logger = rootLogger.child({ name: "main-window" });
import { actions } from "common/actions";
type AppCommand = "browser-backward" | "browser-forward";
const BOUNDS_CONFIG_KEY = "main_window_bounds";
const MAXIMIZED_CONFIG_KEY = "main_window_maximized";
const macOs = os.platform() === "darwin";
import {
IRootState,
IStore,
INativeWindowState,
ItchWindowRole,
示例9: function
import { Watcher } from "common/util/watcher";
import urlParser from "url";
import rootLogger from "common/logger";
const logger = rootLogger.child({ name: "reactors/url" });
import urls from "common/constants/urls";
import { shell } from "electron";
import { actions } from "common/actions";
import { IStore } from "common/types";
import { filter } from "underscore";
import { call, messages } from "common/butlerd";
import { reportIssue } from "main/crash-reporter";
import { isItchioURL } from "common/util/url";
export default function(watcher: Watcher) {
watcher.on(actions.processUrlArguments, async (store, action) => {
const { args } = action.payload;
for (const uri of args) {
if (isItchioURL(uri)) {
store.dispatch(actions.handleItchioURI({ uri }));
break;
}
}
});
watcher.on(actions.openInExternalBrowser, async (store, action) => {
示例10: cancel
import { Client } from "butlerd";
import rootLogger from "common/logger";
import { messages } from "common/butlerd";
const logger = rootLogger.child({ name: "download-driver" });
export enum Phase {
IDLE,
STARTING,
RUNNING,
CANCELLING,
}
class State {
private client: Client;
private phase: Phase;
constructor() {
this.phase = Phase.IDLE;
}
registerClient(client: Client) {
this.client = client;
this.setPhase(Phase.RUNNING);
}
async cancel() {
this.setPhase(Phase.CANCELLING);
await this.client.call(messages.DownloadsDriveCancel, {});
this.client = null;
}