Skip to content

Commit

Permalink
Filter only yml files
Browse files Browse the repository at this point in the history
Handle trialing slashes

Signed-off-by: Iliya Savov <isavov@users.noreply.github.com>
  • Loading branch information
isavov committed May 25, 2023
1 parent cf8d8dd commit 9d22c42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/utils/cliOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module.exports = class CliOptions {
type: 'string',
describe: 'Path to a directory with user Compose configuration files',
demandOption: false,
default: './overrides',
default: './overrides/',
})
}
}
8 changes: 7 additions & 1 deletion src/utils/nodeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,14 @@ module.exports = class NodeController {
}

static getUserComposeFiles(dirPath = './overrides/') {
dirPath = path.normalize(dirPath);
if (!dirPath.endsWith(path.sep)) {
dirPath += path.sep;
}
if (fs.existsSync(dirPath)) {
const files = fs.readdirSync(dirPath).sort().map(file => dirPath.concat(file));
const files = fs.readdirSync(dirPath)
.filter(file => path.extname(file).toLowerCase() === '.yml')
.sort().map(file => dirPath.concat(file));
return files;
} else {
return [];
Expand Down

0 comments on commit 9d22c42

Please sign in to comment.