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


TypeScript execa.sync函数代码示例

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


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

示例1: listCommits

export function listCommits(from: string, to: string = ""): CommitListItem[] {
  // Prints "<short-hash>;<ref-name>;<summary>;<date>"
  // This format is used in `getCommitInfos` for easily analize the commit.
  return execa
    .sync("git", ["log", "--oneline", "--pretty=%h;%D;%s;%cd", "--date=short", `${from}..${to}`])
    .stdout.split("\n")
    .filter(Boolean)
    .map((commit: string) => {
      const parts = commit.split(";");
      const sha = parts[0];
      const refName = parts[1];
      const summary = parts[2];
      const date = parts[3];
      return { sha, refName, summary, date };
    });
}
开发者ID:lerna,项目名称:lerna-changelog,代码行数:16,代码来源:git.ts

示例2: loadEnv

export function loadEnv(cwd: string): IEnvironment {
	const shim: string = getShim();
	const env: IEnvironment = {};
	const { stdout, stderr } = execa.sync(shim, [], {
		cwd,
	});

	console.error(stderr);

	for (const line of stdout.split('\n')) {
		const result: string[] = processExportLine(line);
		const name = result[0];
		if (RUBY_ENVIRONMENT_VARIABLES.indexOf(name) >= 0) {
			env[name] = result[1];
		}
	}

	return env;
}
开发者ID:rubyide,项目名称:vscode-ruby,代码行数:19,代码来源:env.ts

示例3: execSync

function execSync(command, args, opts) {
	return execa.sync(command, args, opts).stdout;
}
开发者ID:sutarmin,项目名称:dx-platform,代码行数:3,代码来源:child-process.utils.ts

示例4: lastTag

export function lastTag(): string {
  return execa.sync("git", ["describe", "--abbrev=0", "--tags"]).stdout;
}
开发者ID:lerna,项目名称:lerna-changelog,代码行数:3,代码来源:git.ts

示例5: listTagNames

export function listTagNames(): string[] {
  return execa
    .sync("git", ["tag"])
    .stdout.split("\n")
    .filter(Boolean);
}
开发者ID:lerna,项目名称:lerna-changelog,代码行数:6,代码来源:git.ts

示例6: load

export function load(options: ConfigLoaderOptions = {}): Configuration {
  let cwd = process.cwd();
  let rootPath = execa.sync("git", ["rev-parse", "--show-toplevel"], { cwd }).stdout;

  return fromPath(rootPath, options);
}
开发者ID:lerna,项目名称:lerna-changelog,代码行数:6,代码来源:configuration.ts

示例7: sync

export const osascriptSync = (filePath: string, ...args: string[]): string =>
  sync('osascript', [filePath, ...args]).stdout;
开发者ID:JamieMason,项目名称:ImageOptim-CLI,代码行数:2,代码来源:osascript.ts

示例8: Error

export const run = (cmd: string, cwd?: Config.Path): RunResult => {
  const args = cmd.split(/\s/).slice(1);
  const spawnOptions = {cwd, preferLocal: false, reject: false};
  const result = spawnSync(cmd.split(/\s/)[0], args, spawnOptions) as RunResult;

  // For compat with cross-spawn
  result.status = result.code;

  if (result.status !== 0) {
    const message = `
      ORIGINAL CMD: ${cmd}
      STDOUT: ${result.stdout}
      STDERR: ${result.stderr}
      STATUS: ${result.status}
      ERROR: ${result.error}
    `;
    throw new Error(message);
  }

  return result;
};
开发者ID:Volune,项目名称:jest,代码行数:21,代码来源:Utils.ts

示例9: Error

export const runTest = (source: string) => {
  const filename = crypto
    .createHash('md5')
    .update(source)
    .digest('hex');
  const tmpFilename = path.join(os.tmpdir(), filename);

  const content = `
    require('${BABEL_REGISTER_PATH}')({extensions: [".js", ".ts"]});
    const circus = require('${CIRCUS_PATH}');
    global.test = circus.test;
    global.describe = circus.describe;
    global.beforeEach = circus.beforeEach;
    global.afterEach = circus.afterEach;
    global.beforeAll = circus.beforeAll;
    global.afterAll = circus.afterAll;

    const testEventHandler = require('${TEST_EVENT_HANDLER_PATH}').default;
    const addEventHandler = require('${CIRCUS_STATE_PATH}').addEventHandler;
    addEventHandler(testEventHandler);

    ${source};

    const run = require('${CIRCUS_RUN_PATH}').default;

    run();
  `;

  fs.writeFileSync(tmpFilename, content);
  const result = spawnSync('node', [tmpFilename], {
    cwd: process.cwd(),
  }) as Result;

  // For compat with cross-spawn
  result.status = result.code;

  if (result.status !== 0) {
    const message = `
      STDOUT: ${result.stdout && result.stdout.toString()}
      STDERR: ${result.stderr && result.stderr.toString()}
      STATUS: ${result.status}
      ERROR: ${String(result.error)}
    `;
    throw new Error(message);
  }

  result.stdout = String(result.stdout);
  result.stderr = String(result.stderr);

  fs.unlinkSync(tmpFilename);

  if (result.stderr) {
    throw new Error(
      `
      Unexpected stderr:
      ${result.stderr}
    `,
    );
  }
  return result;
};
开发者ID:facebook,项目名称:jest,代码行数:61,代码来源:testUtils.ts


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