通过 nodegit 克隆 repo 时如何获得状态进度?

How to get a status progress when cloning a repo via nodegit?

我使用 Clone.clone from nodegit and I am looking for a progress status callback. The function has a CheckoutOptions 对象,我这样称呼它:

var opts: CloneOptions = {};
opts.checkoutOpts = {
    progressCb: function() {
        console.log("Foo");
    },
}

但这似乎会使 BrowserWindow 崩溃。有没有人通过查看 CheckoutOptions 的声明我可能做错了什么?

注意,CheckoutOptionsCloneOptions

的成员

export class CheckoutOptions {
    version?: number;
    checkoutStrategy?: number;
    disableFilters?: number;
    dirMode?: number;
    fileMode?: number;
    fileOpenFlags?: number;
    notifyFlags?: number;
    notifyCb?: any;
    notifyPayload?: undefined;
    progressCb?: any;
    progressPayload?: undefined;
    paths?: Strarray | string | string[];
    baseline?: Tree;
    baselineIndex?: Index;
    targetDirectory?: string;
    ancestorLabel?: string;
    ourLabel?: string;
    theirLabel?: string;
    perfdataCb?: any;
    perfdataPayload?: undefined;
    [key: string]: any;
}

export class CloneOptions {
    version?: number;
    checkoutOpts?: CheckoutOptions;
    fetchOpts?: FetchOptions;
    bare?: number;
    local?: number;
    checkoutBranch?: string;
    repositoryCbPayload?: any;
    remoteCbPayload?: any;
}

尝试使用 new CheckoutOptions() 初始化结帐选项,而不是仅使用空对象 {}

此版本有效:

var opts = {};
opts.checkoutOpts = new CheckoutOptions();
opts.checkoutOpts.progressCb = function(){
    console.log("Foo");
};

此版本崩溃:

var opts = {};
opts.checkoutOpts = {};
opts.checkoutOpts.progressCb = function(){
    console.log("Foo");
};