當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。