本文整理匯總了TypeScript中commandpost.exec函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript exec函數的具體用法?TypeScript exec怎麽用?TypeScript exec使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了exec函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: expand
opts: {
replace: replace,
baseDir: baseDir,
formattersDir: formattersDir,
dryRun: dryRun,
tslint: tslint,
tslintRulesDir: tslintRulesDir,
verbose: verbose,
}
})
.then(showResultHandler)
.catch(errorHandler);
});
commandpost
.exec(root, process.argv)
.catch(errorHandler);
function expand(inputFileList: string[]): string[]
{
const result: string[] = [];
const rootPath = process.cwd();
inputFileList.forEach(fileName =>
{
fileName = path.resolve(rootPath, fileName);
const fileStats = fs.statSync(fileName);
if (fileStats.isDirectory())
{
const fileList: string[] = [];
walkSync(fileName, fileList);
示例2: await
const namespace = opts.namespace[0];
const withQuery = opts.withQuery;
const sortProps = opts.sortProps;
const input = await (args.input_filename ? fromFile(args.input_filename) : fromStdin());
const model = await convert(YAML.safeLoad(input), { namespace, withQuery, sortProps });
if (outputFilename) {
fs.writeFileSync(outputFilename, model);
} else {
process.stdout.write(model);
}
process.exit(0);
});
commandpost.exec(root, process.argv).catch(errorHandler);
function fromStdin() {
process.stdin.setEncoding("utf-8");
return new Promise<string>((resolve, reject) => {
let data = "";
process.stdin
.on("data", chunk => (data += chunk))
.once("end", () => resolve(data))
.once("error", err => reject(err));
setTimeout(() => {
if (data) {
return;
}
reject();
}, 1000);