Skip to content

Commit

Permalink
fix: added __dirname instead of absolute path (#255)
Browse files Browse the repository at this point in the history
Co-authored-by: Khuda Dad Nomani <32505158+KhudaDad414@users.noreply.github.com>
  • Loading branch information
omidNM24 and KhudaDad414 authored Apr 18, 2024
1 parent b533bac commit 37b6cfb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions examples/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { Optimizer } = require('../lib/Optimizer')
const fs = require('fs')
const path = require('path')

// read input.yaml file synconously and store it as an string
const input = require('fs').readFileSync('./examples/input.yaml', 'utf8')
// Construct absolute paths to input and output files
const inputFilePath = path.join(__dirname, 'input.yaml')
const outputFilePath = path.join(__dirname, 'output.yaml')

// Read input.yaml file synchronously and store it as a string
const input = fs.readFileSync(inputFilePath, 'utf8')
const optimizer = new Optimizer(input)

optimizer.getReport().then((report) => {
console.log(report)
const optimizedDocument = optimizer.getOptimizedDocument({
Expand All @@ -18,6 +25,7 @@ optimizer.getReport().then((report) => {
schema: false,
},
})
//store optimizedDocument as to output.yaml
require('fs').writeFileSync('./examples/output.yaml', optimizedDocument)

// Store optimizedDocument to output.yaml
fs.writeFileSync(outputFilePath, optimizedDocument)
})

0 comments on commit 37b6cfb

Please sign in to comment.