本文整理匯總了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;
};