Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added __dirname instead of absolute path #255

Merged
merged 3 commits into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
})
Loading