本文整理汇总了TypeScript中execa.stdout函数的典型用法代码示例。如果您正苦于以下问题:TypeScript stdout函数的具体用法?TypeScript stdout怎么用?TypeScript stdout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了stdout函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
const ensureMasterBranch = async () => {
const currentBranch = await execa.stdout('git', ['symbolic-ref', '--short', 'HEAD']);
const status = await execa.stdout('git', ['status', '--porcelain']);
if (currentBranch !== 'master' && status !== '') {
console.error(chalk.red.bold('You need to be on clean master branch to release @grafana/ui'));
process.exit(1);
}
};
示例2: catch
const availableCommands = await Promise.all(commands.map(async command => {
try {
await execa.stdout('which', [command.command]);
return command;
} catch (error) {
return false;
}
}));
示例3: async
export const runImageOptim: AppRunner = async (options) => {
info(`Running ${IMAGEOPTIM.name}...`);
if (!(await pathExists(IMAGEOPTIM_BIN_PATH))) {
return warning(`ImageOptim.app is not installed (${IMAGEOPTIM_URL})`);
}
await stdout(IMAGEOPTIM_BIN_PATH, [options.tmpDir]);
verbose(`${IMAGEOPTIM.name} has finished`);
};
示例4: async
async ({ log }) => {
const files = await execa.stdout('git', ['ls-tree', '--name-only', '-r', 'HEAD'], {
cwd: REPO_ROOT,
});
const isNotInTsProject: File[] = [];
const isInMultipleTsProjects: File[] = [];
for (const lineRaw of files.split('\n')) {
const line = lineRaw.trim();
if (!line) {
continue;
}
const file = new File(resolve(REPO_ROOT, line));
if (!file.isTypescript() || file.isFixture()) {
continue;
}
log.verbose('Checking %s', file.getAbsolutePath());
const projects = PROJECTS.filter(p => p.isAbsolutePathSelected(file.getAbsolutePath()));
if (projects.length === 0) {
isNotInTsProject.push(file);
}
if (projects.length > 1 && !file.isTypescriptAmbient()) {
isInMultipleTsProjects.push(file);
}
}
if (!isNotInTsProject.length && !isInMultipleTsProjects.length) {
log.success('All ts files belong to a single ts project');
return;
}
if (isNotInTsProject.length) {
log.error(
`The following files do not belong to a tsconfig.json file, or that tsconfig.json file is not listed in src/dev/typescript/projects.ts\n${isNotInTsProject
.map(file => ` - ${file.getRelativePath()}`)
.join('\n')}`
);
}
if (isInMultipleTsProjects.length) {
log.error(
`The following files belong to multiple tsconfig.json files listed in src/dev/typescript/projects.ts\n${isInMultipleTsProjects
.map(file => ` - ${file.getRelativePath()}`)
.join('\n')}`
);
}
process.exit(1);
},
示例5: async
async () => {
await expect(
execa.stdout('tsc', ['--noEmit'], {
cwd: resolve(__dirname, '__fixtures__/frozen_object_mutation'),
})
).rejects.toThrowErrorMatchingInlineSnapshot(`
"Command failed: tsc --noEmit
index.ts(30,11): error TS2540: Cannot assign to 'baz' because it is a read-only property.
index.ts(40,10): error TS2540: Cannot assign to 'bar' because it is a read-only property.
"
`);
},
示例6: execa
execa('foo')
.catch(error => {
assert(error.cmd === 'foo');
assert(error.code === 128);
assert(error.failed === true);
assert(error.killed === false);
assert(error.signal === 'SIGINT');
assert(error.stderr === 'stderr');
assert(error.stdout === 'stdout');
assert(error.timedOut === false);
});
execa('noop', ['foo'])
.then(result => result.stderr.toLocaleLowerCase());
execa.stdout('unicorns')
.then(stdout => stdout.toLocaleLowerCase());
execa.stdout('echo', ['unicorns'])
.then(stdout => stdout.toLocaleLowerCase());
execa.stderr('unicorns')
.then(stderr => stderr.toLocaleLowerCase());
execa.stderr('echo', ['unicorns'])
.then(stderr => stderr.toLocaleLowerCase());
execa.shell('echo unicorns')
.then(result => result.stdout.toLocaleLowerCase());
{
let result: string;
result = execa.shellSync('foo').stderr;
示例7: async
export const runImageOptim: AppRunner = async (options) => {
info(`Running ${IMAGEOPTIM.name}...`);
await stdout(IMAGEOPTIM_BIN_PATH, [options.tmpDir]);
verbose(`${IMAGEOPTIM.name} has finished`);
};
示例8: stdout
export const osascript = (filePath: string, ...args: string[]): Promise<string> =>
stdout('osascript', [filePath, ...args]);