Skip to content

Commit 181ac33

Browse files
committed
feat(internals): add ensureArray
1 parent edec35a commit 181ac33

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/internals.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,23 @@ function collect(val, memo) {
102102
return memo;
103103
}
104104

105+
function ensureArray(arg) {
106+
if (arg === undefined || arg === null || arg === '') {
107+
return [];
108+
}
109+
110+
if (!Array.isArray(arg)) {
111+
return [arg];
112+
}
113+
114+
return arg;
115+
}
116+
105117
module.exports = {
106118
preprocessArgs,
107119
fileExists,
108120
parseConfigActions,
109121
parseConfig,
110-
collect
122+
collect,
123+
ensureArray
111124
};

0 commit comments

Comments
 (0)