Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
read-config
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Дмитрий Никулин
read-config
Commits
87bb1aba
Commit
87bb1aba
authored
Oct 26, 2017
by
Дмитрий Никулин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for object configs
parent
77102399
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
index.js
index.js
+11
-5
No files found.
index.js
View file @
87bb1aba
...
...
@@ -2,13 +2,19 @@ const { readFileSync } = require('fs');
const
{
merge
}
=
require
(
'lodash'
);
module
.
exports
=
function
(
filenames
,
logger
)
{
const
configs
=
filenames
.
map
(
filename
=>
loadAndParseFile
(
filename
,
logger
||
console
))
.
filter
(
string
=>
string
!==
null
);
module
.
exports
=
function
(
items
,
logger
)
{
const
configs
=
items
.
map
(
item
=>
{
// Assume that strings are filenames
if
(
typeof
item
===
'string'
)
{
return
loadAndParseFile
(
item
,
logger
||
console
);
}
return
item
;
})
.
filter
(
item
=>
item
!==
null
);
if
(
!
configs
.
length
)
{
throw
new
Error
(
`Failed to read each of these config files:
${
filename
s
.
join
(
', '
)}
`
);
throw
new
Error
(
`Failed to read each of these config files:
${
item
s
.
join
(
', '
)}
`
);
}
return
merge
(
configs
[
0
],
...
configs
.
slice
(
1
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment