当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript safe.italic函数代码示例

本文整理汇总了TypeScript中colors/safe.italic函数的典型用法代码示例。如果您正苦于以下问题:TypeScript italic函数的具体用法?TypeScript italic怎么用?TypeScript italic使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了italic函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: push

    export function push(options: any) {
        if (!!options.quiet) log.silence();
        let repo = cwdRepo();

        let url = conf.get('repo_' + repo.name + '.url');
        if (!url) {
            log.error(`remote address not specified. Use ${colors.bold('jerk config set this.url <url>')} to set remote address to ${colors.italic('<url>')}`);
            return;
        }

        var mode = conf.get('repo_' + repo.name + '.mode');
        if (!mode) mode = 'rsync';
        if (mode !== 'rsync' && mode !== 'http') {
            log.error(`unknown connection mode. Supported modes are: ${colors.italic('rsync')} and ${colors.italic('http')}`);
            return;
        }

        Client.push(repo, url, mode, () => {
            log.error('cannot push to remote server, pull remote changes and try again.');
        }, progressBarCallback(), (res: Client.PushSuccessState) => {
            switch (res) {
                case Client.PushSuccessState.UP_TO_DATE:
                    log.success('up-to-date!');
                    break;
                case Client.PushSuccessState.CONNECTION_FAILED:
                    log.error('connection to remote failed!');
                    break;
                case Client.PushSuccessState.OK:
                    log.success('push finished successfully!');
                    break;
                case Client.PushSuccessState.FAIL:
                default:
                    log.error('error occured while pushing to remote!');
                    break;
            }
        });
    }
开发者ID:ssyp-ru,项目名称:ssyp16-ws13,代码行数:37,代码来源:cli.ts

示例2: uploadObjectsHTTP

 function uploadObjectsHTTP(remote: { host: string; port: number }, callback: Function) {
     log.error(`HTTP upload mode not implemented! Use ${colors.italic('rsync')} mode.`);
     /*
     let client = net.createConnection({ host: remote.host, port: remote.port + 4 }, () => {
         log.success('connected to remote...');
         //client.write();
     });
     client.on('data', (data) => {
         console.log(data.toString());
         client.end();
     });
     client.on('end', () => {
         log.success('disconnected from remote');
     });
     */
 }
开发者ID:STALKER2010,项目名称:jerk,代码行数:16,代码来源:cli.ts

示例3: push

    export function push(options: any) {
        if (!!options.quiet) log.silence();
        let repo = cwdRepo();

        let url = conf.get('repo_' + repo.name + '.url');
        if (!url) {
            log.error(`remote address not specified. Use ${colors.bold('jerk config set this.url <url>')} to set remote address to ${colors.italic('<url>')}`);
            return;
        }

        var mode = conf.get('repo_' + repo.name + '.mode');
        if (!mode) mode = 'rsync';
        if (mode !== 'rsync' && mode !== 'http') {
            log.error(`unknown connection mode. Supported modes are: ${colors.italic('rsync')} and ${colors.italic('http')}`);
            return;
        }

        fetchConfig(url, (cfg) => {
            cfg = JSON.parse(cfg);
            let data = fastForwardable(repo, cfg);
            if (!data) return;

            let newCommits = repo.commits
                .map(x => (data.remoteCommits.indexOf(x.id) < 0) ? x : null)
                .filter(x => !!x)
                .map(x => x.data());
            let newRefs = repo.refs()
                .map(x => (data.remoteRefs.indexOf(x.name) < 0 && x.name !== 'HEAD') ? x : null)
                .filter(x => !!x)
                .map(x => x.data());
            let changedRefs = data.changedRefs
                .map(x => repo.ref(x).data());

            if (newCommits.length === 0 && newRefs.length === 0 && changedRefs.length === 0) {
                return log.success('up-to-date!');
            }

            let refs = {};
            let commits = {};
            newRefs.concat(changedRefs).forEach(x => refs[x[1]] = x);
            newCommits.forEach(x => commits[x[1]] = x);

            let json = {
                refs: refs,
                commits: commits,
                revision: cfg.revision
            }

            let remote = parseRemoteAddress(url);

            let jsonPush = JSON.stringify(json);

            pushJSON(remote, jsonPush, (res) => {
                if (!res) {
                    log.error('push connection failed');
                    return;
                }
                if (res === 'OK') {
                    uploadObjects(remote, mode, (res) => {
                        if (res) return log.success('push finished successfully!');
                        return log.error('uploading objects failed');
                    });
                    return;
                }
                log.error('remote:', res);
            });
        });
    }
开发者ID:STALKER2010,项目名称:jerk,代码行数:68,代码来源:cli.ts

示例4: pull

    export function pull(options: any) {
        if (!!options.quiet) log.silence();
        let repo = cwdRepo();

        let url = conf.get('repo_' + repo.name + '.url');
        if (!url) {
            log.error(`remote address not specified. Use ${colors.bold('jerk config set this.url <url>')} to set remote address to ${colors.italic('<url>')}`);
            return;
        }

        let remote = parseRemoteAddress(url);

        let bar = new ProgressBar('  remote [:bar] :percent :etas', { total: 100, clear: true });

        let cp = child_process.spawn("rsync",
            [`rsync://${remote.host}:${remote.port}/jerk/objects`, '--info=progress2',
                '-E', '-hhh', '-r', '-u', '--delete-delay', '.jerk']);
        cp.stdout.on('data', (stdout) => {
            rsyncOutputProgressUpdate(stdout, bar);
        });
        let cpInterval = setInterval(() => bar.tick(0), 100);

        fetchConfig(url, (cfg) => {
            Common.iterateStringKeyObject<string[]>(cfg.refs).forEach(v => {
                let ref = repo.ref(v.key);
                let val = v.value;
                if (ref) {
                    ref.name = val[1];
                    ref.head = val[2];
                    ref.time = parseInt(val[3]);
                } else {
                    repo.addRef(new Common.Ref(val[2], val[1], repo, parseInt(val[3])));
                }
            });

            cp.on('exit', (code: number, signal: string) => {
                bar.tick(100);
                clearInterval(cpInterval);
                log.success('pull finished successfully');
            });
        });
    }
开发者ID:STALKER2010,项目名称:jerk,代码行数:42,代码来源:cli.ts

示例5: fetch

    export function fetch(options: any) {
        if (!!options.quiet) log.silence();
        let repo = cwdRepo();

        let url = conf.get('repo_' + repo.name + '.url');
        if (!url) {
            log.error(`remote address not specified. Use ${colors.bold('jerk config set this.url <url>')} to set remote address to ${colors.italic('<url>')}`);
            return;
        }

        Client.fetch(repo, url, progressBarCallback(), (success) => {
            if (success) {
                log.success('fetch finished successfully');
            } else {
                log.error('fetch failed');
            }
        });
    }
开发者ID:ssyp-ru,项目名称:ssyp16-ws13,代码行数:18,代码来源:cli.ts

示例6: pull

    export function pull(options: any) {
        if (!!options.quiet) log.silence();
        let repo = cwdRepo();

        let url = conf.get('repo_' + repo.name + '.url');
        if (!url) {
            log.error(`remote address not specified. Use ${colors.bold('jerk config set this.url <url>')} to set remote address to ${colors.italic('<url>')}`);
            return;
        }

        if (!repo.currentBranchName) {
            log.error(`you can not pull in detached HEAD state. Create new branch or use ${colors.bold('jerk fetch')}.`);
            return;
        }

        Client.fetch(repo, url, progressBarCallback(), (success) => {
            if (success) {
                let authorName: string = conf.get('authorName');
                let authorEMail: string = conf.get('authorEMail');
                var noAuthor = !authorName || !authorEMail;
                if (noAuthor) {
                    log.error('either author name or email is not specified!');
                    return;
                }
                let resolved = Client.resolveWhat(repo, 'FETCH_HEAD');
                Client.merge(repo, resolved.commit, 'Remote pull merging commit', authorName, authorEMail);
                log.success('pull finished successfully');
            } else {
                log.error('fetch failed');
            }
        });
    }
开发者ID:ssyp-ru,项目名称:ssyp16-ws13,代码行数:32,代码来源:cli.ts

示例7: config

    export function config(op: string, args: string[]) {
        log.header('Configuration Manager');

        switch (op) {
            case "list": {
                log.log(colors.cyan('Global'), 'options:');

                var allConf = Common.iterateStringKeyObject<any>(conf.all);
                allConf.forEach(v => {
                    if (!v.key.startsWith('repo_')) {
                        log.log(v.key, "=", v.value);
                    }
                });

                let repo = Common.cwdRepo();
                if (!!repo) {
                    var lc = conf.get('repo_' + repo.name);
                    if (!!lc) {
                        log.log(colors.cyan('Local repository'), 'options:');

                        Common.iterateStringKeyObject<any>(lc).forEach(v => {
                            log.log(v.key, "=", v.value);
                        });
                    }
                }
                break;
            }
            case "set": {
                if (args.length < 2) {
                    log.error('Not enough arguments for set operation.' +
                        'You must specify both key and value to set.');
                    return;
                }

                var key = args[0];
                let repo = Common.cwdRepo();
                if (key.startsWith('this.')) {
                    if (!repo) {
                        log.error(`You use local repository referencing (${colors.italic('this.')})` +
                            ` while outside of any repository directory. Aborting.`);
                        return;
                    }
                    key = key.replace('this.', 'repo_' + repo.name + '.');
                }
                conf.set(key, args[1]);
                log.log(args[0], '=', conf.get(key));
                break;
            }
            case "delete": {
                let repo = cwdRepo();
                if (args.length < 2) {
                    log.error('Not enough arguments for set operation.' +
                        'You must specify both key and value to set.');
                    return;
                }

                var key = args[0];
                if (key.startsWith('this.')) {
                    key = key.replace('this.', 'repo_' + repo.name + '.');
                }
                conf.set(key, args[1]);
                log.log(args[0], '=', conf.get(key));
                break;
            }
            default: {
                log.error('unknown operation');
                break;
            }
        }
    }
开发者ID:ssyp-ru,项目名称:ssyp16-ws13,代码行数:70,代码来源:cli.ts


注:本文中的colors/safe.italic函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。