Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
fedeci committed Aug 7, 2021
1 parent 49e3e71 commit 28784c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
9 changes: 4 additions & 5 deletions packages/babel-cli/src/babel/options.ts
Expand Up @@ -189,11 +189,10 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {

const errors = [];

let filenames = commander.args.reduce(function (globbed, input) {
let files = glob.sync(input);
if (!files.length) files = [input];
globbed.push(...files);
return globbed;
let filenames = commander.args.flatMap(input => {
const files = glob.sync(input);
if (files.length === 0) return [input];
return files;
}, []);

filenames = Array.from(new Set(filenames));
Expand Down
16 changes: 10 additions & 6 deletions packages/babel-traverse/src/path/family.ts
Expand Up @@ -185,12 +185,16 @@ function getStatementListCompletion(
if (i === paths.length - 1) {
completions.push(...statementCompletions);
} else {
completions.push(
...statementCompletions.filter(c => c.type === BREAK_COMPLETION),
);
lastNormalCompletions = statementCompletions.filter(
c => c.type === NORMAL_COMPLETION,
);
lastNormalCompletions = [];
for (let i = 0; i < statementCompletions.length; i++) {
const c = statementCompletions[i];
if (c.type === BREAK_COMPLETION) {
completions.push(c);
}
if (c.type === NORMAL_COMPLETION) {
lastNormalCompletions.push(c);
}
}
}
}
} else if (paths.length) {
Expand Down

0 comments on commit 28784c5

Please sign in to comment.