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


TypeScript child-process-promise.exec函数代码示例

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


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

示例1: getCurrentVersionFromGitTag

    static async getCurrentVersionFromGitTag(): Promise<string> {
        let result = await cp.exec("git describe --abbrev=0 --tags");
        let content = result.stdout.trim();
        if (!content) {
            return null;
        }

        return content;
    }
开发者ID:928PJY,项目名称:docfx,代码行数:9,代码来源:common.ts

示例2: getJuliaExePath

export async function getJuliaExePath() {
    if (actualJuliaExePath == null) {
        if (g_settings.juliaExePath == null) {
            let homedir = os.homedir();
            let pathsToSearch = [];
            if (process.platform == "win32") {
                pathsToSearch = ["julia.exe",
                    path.join(homedir, "AppData", "Local", "Julia-1.1.0", "bin", "julia.exe"),
                    path.join(homedir, "AppData", "Local", "Julia-1.0.4", "bin", "julia.exe"),
                    path.join(homedir, "AppData", "Local", "Julia-1.0.3", "bin", "julia.exe"),
                    path.join(homedir, "AppData", "Local", "Julia-1.0.2", "bin", "julia.exe"),
                    path.join(homedir, "AppData", "Local", "Julia-1.0.1", "bin", "julia.exe"),
                    path.join(homedir, "AppData", "Local", "Julia-1.0.0", "bin", "julia.exe")                    
                ];
            }
            else if (process.platform == "darwin") {
                pathsToSearch = ["julia",
                    path.join(homedir, "Applications", "Julia-1.1.app", "Contents", "Resources", "julia", "bin", "julia"),
                    path.join("/", "Applications", "Julia-1.1.app", "Contents", "Resources", "julia", "bin", "julia"),
                    path.join(homedir, "Applications", "Julia-1.0.app", "Contents", "Resources", "julia", "bin", "julia"),
                    path.join("/", "Applications", "Julia-1.0.app", "Contents", "Resources", "julia", "bin", "julia")];
            }
            else {
                pathsToSearch = ["julia"];
            }
            let foundJulia = false;
            for (let p of pathsToSearch) {
                try {
                    var res = await exec(`"${p}" --startup-file=no --history-file=no -e "println(Sys.BINDIR)"`);
                    if (p == 'julia' || p == "julia.exe") {
                        // use full path
                        actualJuliaExePath = path.join(res.stdout.trim(), p);
                    } else {
                        actualJuliaExePath = p;
                    }
                    foundJulia = true;
                    break;
                }
                catch (e) {
                }
            }
            if (!foundJulia) {
                actualJuliaExePath = g_settings.juliaExePath;
            }
        }
        else {
            if (g_settings.juliaExePath.includes(path.sep)) {
                actualJuliaExePath = g_settings.juliaExePath;
            } else {
                // resolve full path
                actualJuliaExePath = await whichAsync(g_settings.juliaExePath);
            }
        }
    }
    return actualJuliaExePath;
}
开发者ID:JuliaEditorSupport,项目名称:julia-vscode,代码行数:56,代码来源:juliaexepath.ts

示例3: verifyCert

function verifyCert(cert: string, intermediates: string[], roots: string[]) {
  let cmd = ['openssl', 'verify'];
  for (let intermediate of intermediates) {
    cmd.push(...['-untrusted', intermediate]);
  }
	for (let root of roots) {
      cmd.push(...['-CAfile', root]);
    }
	cmd.push(cert);
  return exec(cmd.join(' '));
}
开发者ID:pxpeterxu,项目名称:xar-js,代码行数:11,代码来源:generate-cert-chain.ts

示例4: bakeGrapherUrls

export async function bakeGrapherUrls(urls: string[], opts: { silent?: boolean } = {}) {
    const currentExports = await getGrapherExportsByUrl()
    const slugToId = await mapSlugsToIds()
    const toBake = []

    // Check that we need to bake this url, and don't already have an export
    for (const url of urls) {
        const current = currentExports.get(url)
        if (!current) {
            toBake.push(url)
            continue
        }

        const slug = _.last(parseUrl(url).pathname.split('/'))
        if (!slug) {
            console.error(`Invalid chart url ${url}`)
            continue
        }

        const chartId = slugToId[slug]  
        const rows = await grapherDb.query(`SELECT charts.config->>"$.version" AS version FROM charts WHERE charts.id=?`, [chartId])
        if (!rows.length) {
            console.error(`Mysteriously missing chart by id ${chartId}`)
            continue
        }

        if (rows[0].version > current.version) {
            toBake.push(url)
        }
    }

    if (toBake.length > 0) {
        const args = [`${GRAPHER_DIR}/dist/src/bakeChartsToImages.js`]
        args.push(...toBake)
        args.push(`${BAKED_DIR}/exports`)
        const promise = exec(`cd ${GRAPHER_DIR} && node ${args.map(arg => JSON.stringify(arg)).join(" ")}`)
        if (!opts.silent)
            promise.childProcess.stdout.on('data', (data: any) => console.log(data.toString().trim()))
        await promise    
    }

}
开发者ID:OurWorldInData,项目名称:owid-theme,代码行数:42,代码来源:grapherUtil.ts

示例5: execute

function execute(command: string): Promise<Buffer> {
    var configuration = vscode.workspace.getConfiguration('codegnuglobal');
    var encoding = configuration.get<string>('encoding');
    var output = 'utf8';
    if (encoding != null && encoding != "") {
        output = 'binary';
    }
    return exec(command, {
        cwd: vscode.workspace.rootPath,
        encoding: output
    }).then(function(result): Buffer {
        if (encoding != null && encoding != "") {
            var decoded = iconv.decode(result.stdout, encoding);
            return decoded;
        }
        return result.stdout;
    }).fail(function(error) {
        console.error("Error: " + error);
    }).progress(function(childProcess) {
        console.log("Command: " + command + " running...");
    });
};
开发者ID:bbenoist,项目名称:code-gnu-global,代码行数:22,代码来源:global.ts

示例6: signCert

function signCert(requestName: string,
  childCert: string,
  parentCert: string,
  parentCertKey: string,
  serial: string,
  opts: SigningOpts = {}) {
  let cmd = ['openssl', 'x509', '-req', '-in', requestName, '-CAkey', parentCertKey,
    '-CA', parentCert, '-days', '360', '-set_serial', serial, '-sha1',
    '-out', childCert];
  if (opts.enableCAUsage) {
    // mark the certificate as being usable for signing other certificates.
    // See https://www.openssl.org/docs/manmaster/apps/req.html and
    // http://stackoverflow.com/a/5795827/434243
    let extFile = '/tmp/cert-extensions.cfg';
    fs.writeFileSync(extFile, `
[v3_extensions]
basicConstraints=CA:true
`);
    cmd.push(...['-extfile', extFile, '-extensions', 'v3_extensions']);
  }
  return exec(cmd.join(' '));
}
开发者ID:pxpeterxu,项目名称:xar-js,代码行数:22,代码来源:generate-cert-chain.ts

示例7:

import * as cpp from "child-process-promise";

import {
    ChildProcess
} from 'child_process';

const a = cpp.exec("echo \"Hello world!\"");
a.childProcess; // $ExpectType ChildProcess

(async () => {
    const at = await a;
    at.childProcess; // $ExpectType ChildProcess
    at.stdout; // $ExpectType string
    at.stderr; // $ExpectType string
})();
开发者ID:ChaosinaCan,项目名称:DefinitelyTyped,代码行数:15,代码来源:child-process-promise-tests.ts


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