本文整理汇总了TypeScript中execa.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript execa.default方法的具体用法?TypeScript execa.default怎么用?TypeScript execa.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类execa
的用法示例。
在下文中一共展示了execa.default方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: execa
async () => {
const { stdout } = await execa('stdin', {
input: 'hello',
stdio: [null, 'ignore', null]
});
assert(stdout === null);
};
示例2: PassThrough
async () => {
const s = new PassThrough();
s.write('howdy');
s.end();
const { stdout } = await execa('stdin', { input: s });
assert(stdout === 'foobar');
};
示例3: async
const getSsim = async ({ toolName, imageName }: ISubject) => {
const original = getPath({ toolName: 'photoshop', imageName });
const optimised = getPath({ toolName, imageName });
const { stdout } = await execa('pyssim', [original, optimised]);
const ssim = parseFloat(stdout);
return ssim;
};
示例4: notInstalledErr
.then(exists => {
log('found %s ?', exePath, exists)
if (!exists) {
throw notInstalledErr(`Browser ${name} file not found at ${exePath}`)
}
// on Windows using "--version" seems to always start the full
// browser, no matter what one does.
const args: [string] = [
'datafile',
'where',
`name="${doubleEscape(exePath)}"`,
'get',
'Version',
'/value'
]
return execa('wmic', args)
.then(result => result.stdout)
.then(trim)
.then(tap(log))
.then(getVersion)
.then((version: string) => {
log("browser %s at '%s' version %s", name, exePath, version)
return {
name,
version,
path: exePath
}
})
})
示例5: cache
const getLatLon = cache('latlon', async () => {
debug('fetching lat/lon...')
const { stdout } = await execa('whereami')
let lines = stdout.split('\n')
let lat = (lines.find(l => l.startsWith('Latitude:')) as string).split(': ')[1]
let lon = (lines.find(l => l.startsWith('Longitude:')) as string).split(': ')[1]
return { lat, lon }
})
示例6: tsc
async function tsc(out, cwd, optModule, optTarget) {
await fs.remove(out);
return exec(
'tsc',
['--module', optModule, '--outDir', out, '--target', optTarget],
{ cwd }
)
.catch(e => e)
.then(r => r.stdout);
}
示例7: _spawn
// eslint-disable-next-line no-underscore-dangle
function _spawn(command, args, opts) {
children += 1;
const child = execa(command, args, opts);
const drain = (code, signal) => {
children -= 1;
// don't run repeatedly if this is the error event
if (signal === undefined) {
child.removeListener('exit', drain);
}
};
child.once('exit', drain);
child.once('error', drain);
return child;
}
示例8: getVersionString
export function getVersionString(path: string) {
const doubleEscape = (s: string) => s.replace(/\\/g, '\\\\')
// on Windows using "--version" seems to always start the full
// browser, no matter what one does.
const args = [
'datafile',
'where',
`name="${doubleEscape(path)}"`,
'get',
'Version',
'/value'
]
return execa('wmic', args)
.then(result => result.stdout)
.then(trim)
}