forked from bencao/netlify-plugin-inline-functions-env
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.js
40 lines (34 loc) · 761 Bytes
/
lib.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
function normalizeInputValue(singleOrArrayValue) {
if (!singleOrArrayValue) {
return singleOrArrayValue
} else if (Array.isArray(singleOrArrayValue)) {
return singleOrArrayValue
} else {
return [singleOrArrayValue]
}
}
function isJsFunction({ runtime, extension, srcFile }) {
return (
(runtime === 'js' || runtime === 'ts') &&
(extension === '.js' || extension === '.ts') &&
!srcFile.includes('node_modules')
)
}
function getSrcFile({ srcFile }) {
return srcFile
}
function uniq(items) {
const uniqItems = []
items.forEach((item) => {
if (!uniqItems.includes(item)) {
uniqItems.push(item)
}
})
return uniqItems
}
module.exports = {
normalizeInputValue,
isJsFunction,
getSrcFile,
uniq,
}