perks/codemodel-v3/process-code-model.ts

18 строки
989 B
TypeScript
Исходник Постоянная ссылка Обычный вид История

2019-08-28 22:11:40 +03:00
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Model } from './code-model/code-model';
2019-09-03 21:02:12 +03:00
import { serialize } from '@azure-tools/codegen';
import { Host } from '@azure-tools/autorest-extension-base';
2019-08-28 22:11:40 +03:00
import { ModelState } from './model-state';
export async function processCodeModel(processExtension: (state: ModelState<Model>) => Promise<Model>, service: Host, callerName?: string) {
// Get the list of files
const state = await new ModelState<Model>(service).init();
// output the model back to the pipeline
await service.WriteFile(`code-model-v3${callerName ? `-${callerName}` : ''}.yaml`, serialize(await processExtension(state)), undefined, 'code-model-v3');
}