bajo 2.25.0 → 2.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/class/bajo.js +3 -3
- package/package.json +1 -1
- package/test/unit/bajo.test.js +1 -1
- package/wiki/CHANGES.md +2 -0
package/class/bajo.js
CHANGED
|
@@ -1143,7 +1143,7 @@ class Bajo extends Plugin {
|
|
|
1143
1143
|
* @param {object} [options={}] - Options to be passed to the config handlers.
|
|
1144
1144
|
* @returns {Object|Array|null} The result from the first successful config handler, or null if none succeed.
|
|
1145
1145
|
*/
|
|
1146
|
-
|
|
1146
|
+
parseConfig = async (input, exts, options = {}) => {
|
|
1147
1147
|
let result
|
|
1148
1148
|
options.readFromFile = false
|
|
1149
1149
|
const handlers = exts ? this.app.configHandlers.filter(h => exts.includes(h.ext)) : this.app.configHandlers
|
|
@@ -1151,11 +1151,11 @@ class Bajo extends Plugin {
|
|
|
1151
1151
|
if (result) break
|
|
1152
1152
|
try {
|
|
1153
1153
|
const resp = await handler.readHandler.call(this.app[handler.ns], input, options)
|
|
1154
|
-
if (isPlainObject(resp) || isArray(resp)) result = resp
|
|
1154
|
+
if (!isEmpty(resp) && (isPlainObject(resp) || isArray(resp))) result = resp
|
|
1155
1155
|
} catch (err) {
|
|
1156
1156
|
}
|
|
1157
1157
|
}
|
|
1158
|
-
return result
|
|
1158
|
+
return result ?? options.defValue ?? {}
|
|
1159
1159
|
}
|
|
1160
1160
|
}
|
|
1161
1161
|
|
package/package.json
CHANGED
package/test/unit/bajo.test.js
CHANGED
|
@@ -121,7 +121,7 @@ describe('bajo (unit)', () => {
|
|
|
121
121
|
const saved = await bajo.saveAsDownload('file.txt', 'abc', false)
|
|
122
122
|
expect(fs.existsSync(saved)).to.equal(true)
|
|
123
123
|
|
|
124
|
-
const p = await bajo.
|
|
124
|
+
const p = await bajo.parseConfig('{"x":1}', ['.json'])
|
|
125
125
|
expect(p).to.deep.equal({ x: 1 })
|
|
126
126
|
})
|
|
127
127
|
|
package/wiki/CHANGES.md
CHANGED