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


TypeScript ToolRunner.pipeExecOutputToTool方法代码示例

本文整理汇总了TypeScript中azure-pipelines-task-lib/toolrunner.ToolRunner.pipeExecOutputToTool方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ToolRunner.pipeExecOutputToTool方法的具体用法?TypeScript ToolRunner.pipeExecOutputToTool怎么用?TypeScript ToolRunner.pipeExecOutputToTool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在azure-pipelines-task-lib/toolrunner.ToolRunner的用法示例。


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

示例1: getP12PrivateKeyName

export async function getP12PrivateKeyName(p12Path: string, p12Pwd: string): Promise<string> {
    //openssl pkcs12 -in <p12Path> -nocerts -passin pass:"<p12Pwd>" -passout pass:"<p12Pwd>" | grep 'friendlyName'
    tl.debug('getting the P12 private key name');
    const opensslPath: string = tl.which('openssl', true);
    const openssl: ToolRunner = tl.tool(opensslPath);
    if (!p12Pwd) {
        // if password is null or not defined, set it to empty
        p12Pwd = '';
    }
    // since we can't suppress the private key bytes, encrypt them before we pass them to grep.
    const privateKeyPassword = p12Pwd ? p12Pwd : generatePassword();
    openssl.arg(['pkcs12', '-in', p12Path, '-nocerts', '-passin', 'pass:' + p12Pwd, '-passout', 'pass:' + privateKeyPassword]);

    //we pipe through grep so we we don't log the private key to the console.
    //even if it's encrypted, it's noise and could cause concern for some users.
    const grepPath: string = tl.which('grep', true);
    const grep: ToolRunner = tl.tool(grepPath);
    grep.arg(['friendlyName']);
    openssl.pipeExecOutputToTool(grep);

    let privateKeyName: string;
    openssl.on('stdout', function (data) {
        if (data) {
            // find the private key name
            data = data.toString().trim();

            const match = data.match(/friendlyName: (.*)/);
            if (match && match[1]) {
                privateKeyName = match[1].trim();
            }
        }
    });

    await openssl.exec();
    tl.debug('P12 private key name = ' + privateKeyName);
    if (!privateKeyName) {
        throw new Error(tl.loc('P12PrivateKeyNameNotFound', p12Path));
    }

    return privateKeyName;
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:41,代码来源:ios-signing-common.ts

示例2: getP12Properties

export async function getP12Properties(p12Path: string, p12Pwd: string): Promise<{ fingerprint: string, commonName: string, notBefore: Date, notAfter: Date}> {
    //openssl pkcs12 -in <p12Path> -nokeys -passin pass:"<p12Pwd>" | openssl x509 -noout -fingerprint –subject -dates
    let opensslPath: string = tl.which('openssl', true);
    let openssl1: ToolRunner = tl.tool(opensslPath);
    if (!p12Pwd) {
        // if password is null or not defined, set it to empty
        p12Pwd = '';
    }
    openssl1.arg(['pkcs12', '-in', p12Path, '-nokeys', '-passin', 'pass:' + p12Pwd]);

    let openssl2: ToolRunner = tl.tool(opensslPath);
    openssl2.arg(['x509', '-noout', '-fingerprint', '-subject', '-dates']);
    openssl1.pipeExecOutputToTool(openssl2);

    let fingerprint: string;
    let commonName: string;
    let notBefore: Date;
    let notAfter: Date;

    function onLine(line: string) {
        if (line) {
            const tuple = splitIntoKeyValue(line);
            const key: string = tuple.key;
            const value: string = tuple.value;

            if (key === 'SHA1 Fingerprint') {
                // Example value: "BB:26:83:C6:AA:88:35:DE:36:94:F2:CF:37:0A:D4:60:BB:AE:87:0C"
                // Remove colons separating each octet.
                fingerprint = value.replace(/:/g, '').trim();
            } else if (key === 'subject') {
                // Example value: "/UID=E848ASUQZY/CN=iPhone Developer: Chris Sidi (7RZ3N927YF)/OU=DJ8T2973U7/O=Chris Sidi/C=US"
                // Extract the common name.
                const matches: string[] = value.match(/\/CN=([^/]+)/);
                if (matches && matches[1]) {
                    commonName = matches[1].trim();
                }
            } else if (key === 'notBefore') {
                // Example value: "Nov 13 03:37:42 2018 GMT"
                notBefore = new Date(value);
            } else if (key === 'notAfter') {
                notAfter = new Date(value);
            }
        }
    }

    // Concat all of stdout to avoid shearing. This can be updated to `openssl1.on('stdline', onLine)` once stdline mocking is available.
    let output = '';
    openssl1.on('stdout', (data) => {
        output = output + data.toString();
    });

    try {
        await openssl1.exec();

        // process the collected stdout.
        let line: string;
        for (line of output.split('\n')) {
            onLine(line);
        }
    } catch (err) {
        if (!p12Pwd) {
            tl.warning(tl.loc('NoP12PwdWarning'));
        }
        throw err;
    }

    tl.debug(`P12 fingerprint: ${fingerprint}`);
    tl.debug(`P12 common name (CN): ${commonName}`);
    tl.debug(`NotBefore: ${notBefore}`);
    tl.debug(`NotAfter: ${notAfter}`);

    return { fingerprint, commonName, notBefore, notAfter };
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:73,代码来源:ios-signing-common.ts

示例3: run


//.........这里部分代码省略.........
            // in the project file, they should choose the "Project Defaults" signing style.
            xcode_provProfile = `PROVISIONING_PROFILE=${provProfileUUID}`;
            xcode_provProfileSpecifier = `PROVISIONING_PROFILE_SPECIFIER=${provProfileName}`;
        }
        else if (signingOption === 'auto') {
            xcode_codeSignStyle = 'CODE_SIGN_STYLE=Automatic';

            let teamId: string = tl.getInput('teamId');
            if (teamId) {
                xcode_devTeam = 'DEVELOPMENT_TEAM=' + teamId;
            }
        }

        xcb.argIf(xcode_codeSigningAllowed, xcode_codeSigningAllowed);
        xcb.argIf(xcode_codeSignStyle, xcode_codeSignStyle);
        xcb.argIf(xcode_codeSignIdentity, xcode_codeSignIdentity);
        xcb.argIf(xcode_provProfile, xcode_provProfile);
        xcb.argIf(xcode_provProfileSpecifier, xcode_provProfileSpecifier);
        xcb.argIf(xcode_devTeam, xcode_devTeam);

        //--- Enable Xcpretty formatting ---
        if (useXcpretty && !tl.which('xcpretty')) {
            // user wants to enable xcpretty but it is not installed, fallback to xcodebuild raw output
            useXcpretty = false;
            tl.warning(tl.loc("XcprettyNotInstalled"));
        }

        if (useXcpretty) {
            let xcPrettyPath: string = tl.which('xcpretty', true);
            let xcPrettyTool: ToolRunner = tl.tool(xcPrettyPath);
            xcPrettyTool.arg(['-r', 'junit', '--no-color']);

            const logFile: string = utils.getUniqueLogFileName('xcodebuild');
            xcb.pipeExecOutputToTool(xcPrettyTool, logFile);
            utils.setTaskState('XCODEBUILD_LOG', logFile);
        }

        //--- Xcode Build ---
        let buildOnlyDeviceErrorFound: boolean;
        xcb.on('errline', (line: string) => {
            if (!buildOnlyDeviceErrorFound && line.includes('build only device cannot be used to run this target')) {
                buildOnlyDeviceErrorFound = true;
            }
        });

        try {
            await xcb.exec();
        } catch (err) {
            if (buildOnlyDeviceErrorFound) {
                // Tell the user they need to change Destination platform to fix this build error.
                tl.warning(tl.loc('NoDestinationPlatformWarning'));
            }
            throw err;
        }

        //--------------------------------------------------------
        // Package app to generate .ipa
        //--------------------------------------------------------

        if (packageApp && sdk !== 'iphonesimulator') {
            // use xcodebuild to create the app package
            if (!scheme) {
                throw new Error(tl.loc("SchemeRequiredForArchive"));
            }
            if (!ws || !tl.filePathSupplied('xcWorkspacePath')) {
                throw new Error(tl.loc("WorkspaceOrProjectRequiredForArchive"));
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:67,代码来源:xcode.ts


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