本文整理汇总了TypeScript中execa.shell函数的典型用法代码示例。如果您正苦于以下问题:TypeScript shell函数的具体用法?TypeScript shell怎么用?TypeScript shell使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shell函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: main
async function main() {
for (const zoom of range(minzoom, maxzoom + 1)) {
const mbtilesZoom = `${name}-z${zoom}.mbtiles`
const args = [
'--output=' + mbtilesZoom,
'--force',
'--minimum-zoom=' + zoom,
'--maximum-zoom=' + zoom,
'--full-detail=' + (16 - zoom + 16),
'--no-line-simplification',
'--no-feature-limit',
'--no-tile-size-limit',
'--no-polygon-splitting',
'--no-clipping',
'--no-duplication',
name + ext
]
if (verbose) { console.log('Args', args) }
if (verbose) { console.log('Starting zoom', zoom) }
await execa('tippecanoe', args)
if (verbose) { console.log('Finished zoom', zoom) }
await execa.shell(`sqlite3 ${mbtilesZoom} .dump >> ${name}.dump`)
if (verbose) { console.log('Dumped', mbtilesZoom) }
await execa.shell(`rm ${mbtilesZoom}`)
if (verbose) { console.log('Removed', mbtilesZoom) }
}
// Clean
await execa.shell(`sqlite3 ${name}.mbtiles < ${name}.dump`)
if (verbose) { console.log('Merge dump') }
await execa.shell(`rm -f ${name}.dump`)
if (verbose) { console.log('Removed dump') }
console.log('All Done! :)')
}
示例2: async
async () => {
const { stdout } = await execa.shell('noop foo', {
shell: process.platform === 'win32' ? 'cmd.exe' : '/bin/bash'
});
assert(stdout === 'foo');
};
示例3: getVersionString
export function getVersionString(path: string) {
const cmd = `${path} --version`
log('finding version string using command "%s"', cmd)
return execa
.shell(cmd)
.then(result => result.stdout)
.then(trim)
}
示例4: invoke
function invoke(cmd: string, options: IRunOptions = {}) {
const { silent = false } = options;
// Invoke the command.
const promise = execa.shell(cmd);
// Write to console.
if (!silent) {
promise.stdout.pipe(process.stdout);
}
// Finish up.
return promise;
}
示例5: resolve
return new Promise<string>(async (resolve, reject) => {
try {
const config = await gitconfig.getCombinedConfig()
const { gtPrivateKeyPath } = config[`remote "origin"`]
const { name, email } = config.user
const env = {
GIT_SSH_COMMAND: `ssh -i ${gtPrivateKeyPath} -oIdentitiesOnly=yes`,
GIT_COMMITTER_NAME: name,
GIT_COMMITTER_EMAIL: email,
GIT_AUTHOR_NAME: name,
GIT_AUTHOR_EMAIL: email,
}
const result = await execa.shell(command.join(' '), { env })
resolve(result.stdout)
} catch (err) {
reject(err)
}
})
示例6: mdfind
export function mdfind(id: string): Promise<string> {
const cmd = `mdfind 'kMDItemCFBundleIdentifier=="${id}"' | head -1`
log('looking for bundle id %s using command: %s', id, cmd)
const logFound = (str: string) => {
log('found %s at %s', id, str)
return str
}
const failedToFind = () => {
log('could not find %s', id)
throw notInstalledErr(id)
}
return execa
.shell(cmd)
.then(result => result.stdout)
.then(tap(logFound))
.catch(failedToFind)
}
示例7: getLinuxBrowser
function getLinuxBrowser(
name: string,
binary: string,
versionRegex: RegExp
): Promise<FoundBrowser> {
const getVersion = (stdout: string) => {
const m = versionRegex.exec(stdout)
if (m) {
return m[1]
}
log(
'Could not extract version from %s using regex %s',
stdout,
versionRegex
)
return notInstalledErr(binary)
}
const returnError = (err: Error) => {
log('Could not detect browser %s', err.message)
return notInstalledErr(binary)
}
const cmd = `${binary} --version`
log('looking using command "%s"', cmd)
return execa
.shell(cmd)
.then(result => result.stdout)
.then(trim)
.then(tap(log))
.then(getVersion)
.then((version: string) => {
return {
name,
version,
path: binary
}
})
.catch(returnError)
}
示例8: exec
it('should execute migrations', async () => {
const command = `${cliPath} migrate --url ${utils.dbURL}`
await exec(command, {cwd: fixturesPath})
expect(await state.queryInterface.describeTable('users')).toMatchSnapshot()
expect(await state.queryInterface.describeTable('photos')).toMatchSnapshot()
const [indexes] = await state.sequelize.query('show index from users')
expect(indexes.map(index => index.Key_name)).toMatchSnapshot()
})
示例9: it
it('should have created a migration file', async () => {
const command = `${cliPath} migration:bootstrap --kiln-file kiln.js`
const {stdout} = await exec(command, {cwd: fixturesPath})
const filename = stdout.match(/(migrations.*)/)[1].trim()
state.migrationFile = path.join(fixturesPath, filename)
const content = fs.readFileSync(state.migrationFile, 'utf8')
expect(content).toMatchSnapshot()
})