(
plan: MigrationFilePlan,
options: ApplyMigrationPlanOptions = {}
)
| 124 | |
| 125 | /** Writes the exact transformed bytes contained in an already validated plan. */ |
| 126 | export async function applyMigrationPlan( |
| 127 | plan: MigrationFilePlan, |
| 128 | options: ApplyMigrationPlanOptions = {} |
| 129 | ): Promise<readonly MigratedFile[]> { |
| 130 | await preflightPlanOutputs(plan, options); |
| 131 | for (const { outputPath, result } of plan.files) { |
| 132 | await mkdir(dirname(outputPath), { recursive: true }); |
| 133 | await writeFile(outputPath, result.code, 'utf8'); |
| 134 | } |
| 135 | return plan.files; |
| 136 | } |
| 137 | |
| 138 | async function preflightPlanOutputs(plan: MigrationFilePlan, options: ApplyMigrationPlanOptions): Promise<void> { |
| 139 | const outputRoot = resolve(plan.outputRoot); |
no test coverage detected