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: check process on browser #208

Merged
merged 5 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions lib/ini.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const encode = (obj, opt = {}) => {
opt.sort = opt.sort === true
opt.whitespace = opt.whitespace === true || opt.align === true
/* istanbul ignore next */
opt.platform = opt.platform || process?.platform
opt.platform = opt.platform || (typeof process !== 'undefined' && process.platform)
wraithgar marked this conversation as resolved.
Show resolved Hide resolved
opt.bracketedArray = opt.bracketedArray !== false

/* istanbul ignore next */
Expand Down Expand Up @@ -172,8 +172,8 @@ const decode = (str, opt = {}) => {
const remove = []
for (const k of Object.keys(out)) {
if (!hasOwnProperty.call(out, k) ||
typeof out[k] !== 'object' ||
Array.isArray(out[k])) {
typeof out[k] !== 'object' ||
Array.isArray(out[k])) {
continue
}

Expand Down
10 changes: 10 additions & 0 deletions tap-snapshots/test/foo.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,13 @@ label = debug
value = 10

`

exports[`test/foo.js TAP encode within browser context > must match snapshot 1`] = `
[log]
type=file

[log.level]
label=debug
value=10

`
10 changes: 10 additions & 0 deletions test/foo.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,13 @@ test('encode with align and sort', function (t) {
t.matchSnapshot(e)
t.end()
})

test('encode within browser context', function (t) {
process = undefined

const obj = { log: { type: 'file', level: { label: 'debug', value: 10 } } }
const e = i.encode(obj)

t.matchSnapshot(e)
t.end()
})