Skip to content

Commit 25136fb

Browse files
authored
Merge pull request #105 from Automattic/pltfrm-1195-deprecationwarning-passing-invalid-argument-types-to
fix: DEP0169
2 parents 904ac11 + eab09a1 commit 25136fb

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

lib/config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,15 @@ exports.getOclifCacheDir = (product = 'hyperdrive') => env.getOclifCacheDir(prod
193193
*/
194194
exports.loadFiles = files => _(files)
195195
// Filter the source out if it doesn't exist
196-
.filter(source => fs.existsSync(source) || fs.existsSync(source.file))
196+
.filter(source => {
197+
if (typeof source === 'string') {
198+
return fs.existsSync(source);
199+
}
200+
if (typeof source.file === 'string') {
201+
return fs.existsSync(source.file);
202+
}
203+
return false;
204+
})
197205
// If the file is just a string lets map it to an object
198206
.map(source => {
199207
return _.isString(source) ? {file: source, data: yaml.load(fs.readFileSync(source)) || {}} : source;

lib/lando.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ const DEFAULT_VERSIONS = {networking: 1};
1919

2020
// Helper to get init config
2121
const getInitConfig = dirs => _(dirs)
22-
.filter(dir => fs.existsSync(dir))
22+
.filter(dir => typeof dir === 'string' && fs.existsSync(dir))
2323
.flatMap(dir => globSync(path.join(dir, '*', 'init.js')).sort())
2424
.map(file => require(file))
2525
.value();
2626

2727
// Helper to get init source config
2828
const getInitSourceConfig = dirs => _(dirs)
29-
.filter(dir => fs.existsSync(dir))
29+
.filter(dir => typeof dir === 'string' && fs.existsSync(dir))
3030
.flatMap(dir => globSync(path.join(dir, '*.js')).sort())
3131
.map(file => require(file))
3232
.flatMap(source => source.sources)
@@ -69,7 +69,7 @@ const bootstrapTasks = lando => {
6969
// Load in all our tasks
7070
return lando.Promise.resolve(lando.config.plugins)
7171
// Make sure the tasks dir exists
72-
.filter(plugin => fs.existsSync(plugin.tasks))
72+
.filter(plugin => typeof plugin.tasks === 'string' && fs.existsSync(plugin.tasks))
7373
// Get a list off full js files that exist in that dir
7474
.map(plugin => _(fs.readdirSync(plugin.tasks))
7575
.map(file => path.join(plugin.tasks, file))
@@ -108,7 +108,7 @@ const bootstrapEngine = lando => {
108108

109109
// Auto move and make executable any scripts
110110
const pluginPromise = lando.Promise.map(lando.config.plugins, plugin => {
111-
if (fs.existsSync(plugin.scripts)) {
111+
if (typeof plugin.scripts === 'string' && fs.existsSync(plugin.scripts)) {
112112
const confDir = path.join(lando.config.userConfRoot, 'scripts');
113113
const dest = lando.utils.moveConfig(plugin.scripts, confDir);
114114
lando.utils.makeExecutable(fs.readdirSync(dest), dest);
@@ -144,7 +144,7 @@ const bootstrapApp = lando => {
144144
// Load in all our builders in the correct order
145145
const builders = _(['compose', 'types', 'services', 'recipes'])
146146
.flatMap(type => _.map(lando.config.plugins, plugin => plugin[type]))
147-
.filter(dir => fs.existsSync(dir))
147+
.filter(dir => typeof dir === 'string' && fs.existsSync(dir))
148148
.flatMap(dir => globSync(path.join(dir, '*', 'builder.js')).sort())
149149
.map(file => lando.factory.add(require(file)).name)
150150
.value();

0 commit comments

Comments
 (0)