Skip to content

Commit

Permalink
fix: glob-expression
Browse files Browse the repository at this point in the history
  • Loading branch information
serg3295 committed Sep 27, 2024
1 parent 9aafac2 commit c059605
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
6 changes: 4 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
// "-b9600",
// "--debug",
// "--io-debug",
// "upload",
"upload",
"*.lua",
// "*.txt"
// "helloworld.lua"
"fsinfo"
// "fsinfo"
],
"preLaunchTask": "buildDev"
}
Expand Down
11 changes: 4 additions & 7 deletions lib/cli/glob-expression.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
const _isGlob = require("is-glob");
const _glob = require("glob");
const { glob } = require("glob");

async function expandExpression(args) {
// resolve glob expressions async
const resolvedExpressions = await Promise.all(args.map(expr => {
const resolvedExpressions = await Promise.all(args.map(async expr => {
// glob expression ?
if (_isGlob(expr)) {
// expand expression
return _glob(expr, {});
return await glob(expr, {});

// passthrough (e.g. bash/zsh automatically expand glob expressions)
} else {
return Promise.resolve(expr);
}
}));

// flatten array - Array.flat is only availble in Node.js >= 11
return resolvedExpressions.reduce((aggregator, value) => {
return aggregator.concat(value);
}, []);
return resolvedExpressions.flat(resolvedExpressions.length);
}

module.exports = {
Expand Down

0 comments on commit c059605

Please sign in to comment.