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

chore(cli):replaced yaml.js with js-yaml #1342

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
"compare-versions": "^5.0.1",
"concat-stream": "^2.0.0",
"core-js": "^3.26.0",
"js-yaml": "^4.1.0",
"mqtt": "^4.3.7",
"protobufjs": "^7.2.3",
"pump": "^3.0.0",
"readable-stream": "^3.6.0",
"signale": "^1.4.0",
"split2": "^4.1.0",
"yaml": "^2.1.3"
"split2": "^4.1.0"
},
"devDependencies": {
"@faker-js/faker": "^7.6.0",
Expand Down
6 changes: 3 additions & 3 deletions cli/src/utils/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as fs from 'fs'
import path from 'path'
import YAML from 'yaml'
import YAML from 'js-yaml'
import signale from '../utils/signale'

const defaultPath = `${process.cwd()}/mqttx-cli-config.json`
Expand All @@ -11,7 +11,7 @@ const writeFile = (filePath: string, data: Config) => {
try {
fs.mkdirSync(path.dirname(filePath), { recursive: true })
if (filePath.endsWith('.yaml') || filePath.endsWith('.yml')) {
fs.writeFileSync(filePath, YAML.stringify(data))
fs.writeFileSync(filePath, YAML.dump(data))
} else {
fs.writeFileSync(filePath, JSON.stringify(data, null, 2))
}
Expand All @@ -25,7 +25,7 @@ const readFile = (path: string) => {
try {
const config = fs.readFileSync(path, 'utf-8')
if (path.endsWith('.yaml') || path.endsWith('.yml')) {
return YAML.parse(config) as Config
return YAML.load(config) as Config
}
return JSON.parse(config) as Config
} catch (error) {
Expand Down
Loading