Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samteb committed Feb 19, 2024
1 parent 469cefb commit e1c6cbf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apps/authz/src/app/opa/opa.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable, Logger, OnApplicationBootstrap } from '@nestjs/common'
import { loadPolicy } from '@open-policy-agent/opa-wasm'
import { execSync } from 'child_process'
import { readFileSync, writeFileSync } from 'fs'
import { mkdirSync, readFileSync, writeFileSync } from 'fs'
import Handlebars from 'handlebars'
import { indexBy } from 'lodash/fp'
import { ORGANIZATION } from 'packages/authz-shared/src/lib/dev.fixture'
Expand Down Expand Up @@ -65,7 +65,11 @@ export class OpaService implements OnApplicationBootstrap {

const fileId = uuid()

writeFileSync(`./apps/authz/src/opa/rego/generated/${fileId}.rego`, regoContent, 'utf-8')
const basePath = './apps/authz/src/opa/rego/generated'

mkdirSync(basePath, { recursive: true })

writeFileSync(`${basePath}/${fileId}.rego`, regoContent, 'utf-8')

this.logger.log('Policy .rego file generated successfully.')

Expand Down

0 comments on commit e1c6cbf

Please sign in to comment.