本文整理汇总了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 };
});
}
示例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;
}
示例3: execSync
function execSync(command, args, opts) {
return execa.sync(command, args, opts).stdout;
}
示例4: lastTag
export function lastTag(): string {
return execa.sync("git", ["describe", "--abbrev=0", "--tags"]).stdout;
}
示例5: listTagNames
export function listTagNames(): string[] {
return execa
.sync("git", ["tag"])
.stdout.split("\n")
.filter(Boolean);
}
示例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);
}
示例7: sync
export const osascriptSync = (filePath: string, ...args: string[]): string =>
sync('osascript', [filePath, ...args]).stdout;
示例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;
};
示例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;
};