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