Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F76298580
printer.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Aug 7, 06:15
Size
2 KB
Mime Type
text/x-c++
Expires
Fri, Aug 9, 06:15 (2 d)
Engine
blob
Format
Raw Data
Handle
19689768
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
printer.js
View Options
"use strict"
;
Object
.
defineProperty
(
exports
,
"__esModule"
,
{
value
:
true
});
exports
.
ConfigPrinter
=
exports
.
ChainFormatter
=
void
0
;
const
ChainFormatter
=
{
Programmatic
:
0
,
Config
:
1
};
exports
.
ChainFormatter
=
ChainFormatter
;
const
Formatter
=
{
title
(
type
,
callerName
,
filepath
)
{
let
title
=
""
;
if
(
type
===
ChainFormatter
.
Programmatic
)
{
title
=
"programmatic options"
;
if
(
callerName
)
{
title
+=
" from "
+
callerName
;
}
}
else
{
title
=
"config "
+
filepath
;
}
return
title
;
},
loc
(
index
,
envName
)
{
let
loc
=
""
;
if
(
index
!=
null
)
{
loc
+=
`
.
overrides
[
$
{
index
}]
`
;
}
if
(
envName
!=
null
)
{
loc
+=
`
.
env
[
"${envName}"
]
`
;
}
return
loc
;
},
optionsAndDescriptors
(
opt
)
{
const
content
=
Object
.
assign
({},
opt
.
options
);
delete
content
.
overrides
;
delete
content
.
env
;
const
pluginDescriptors
=
[...
opt
.
plugins
()];
if
(
pluginDescriptors
.
length
)
{
content
.
plugins
=
pluginDescriptors
.
map
(
d
=>
descriptorToConfig
(
d
));
}
const
presetDescriptors
=
[...
opt
.
presets
()];
if
(
presetDescriptors
.
length
)
{
content
.
presets
=
[...
presetDescriptors
].
map
(
d
=>
descriptorToConfig
(
d
));
}
return
JSON
.
stringify
(
content
,
undefined
,
2
);
}
};
function
descriptorToConfig
(
d
)
{
var
_d$file
;
let
name
=
(
_d$file
=
d
.
file
)
==
null
?
void
0
:
_d$file
.
request
;
if
(
name
==
null
)
{
if
(
typeof
d
.
value
===
"object"
)
{
name
=
d
.
value
;
}
else
if
(
typeof
d
.
value
===
"function"
)
{
name
=
`
[
Function
:
$
{
d
.
value
.
toString
().
substr
(
0
,
50
)}
...
]
`
;
}
}
if
(
name
==
null
)
{
name
=
"[Unknown]"
;
}
if
(
d
.
options
===
undefined
)
{
return
name
;
}
else
if
(
d
.
name
==
null
)
{
return
[
name
,
d
.
options
];
}
else
{
return
[
name
,
d
.
options
,
d
.
name
];
}
}
class
ConfigPrinter
{
constructor
()
{
this
.
_stack
=
[];
}
configure
(
enabled
,
type
,
{
callerName
,
filepath
})
{
if
(
!
enabled
)
return
()
=>
{};
return
(
content
,
index
,
envName
)
=>
{
this
.
_stack
.
push
({
type
,
callerName
,
filepath
,
content
,
index
,
envName
});
};
}
static
format
(
config
)
{
let
title
=
Formatter
.
title
(
config
.
type
,
config
.
callerName
,
config
.
filepath
);
const
loc
=
Formatter
.
loc
(
config
.
index
,
config
.
envName
);
if
(
loc
)
title
+=
`
$
{
loc
}
`
;
const
content
=
Formatter
.
optionsAndDescriptors
(
config
.
content
);
return
`
$
{
title
}
\
n$
{
content
}
`
;
}
output
()
{
if
(
this
.
_stack
.
length
===
0
)
return
""
;
return
this
.
_stack
.
map
(
s
=>
ConfigPrinter
.
format
(
s
)).
join
(
"\n\n"
);
}
}
exports
.
ConfigPrinter
=
ConfigPrinter
;
Event Timeline
Log In to Comment