Skip to content

Commit 743b052

Browse files
committed
Add path expansion for Windows users, Closes #96
1 parent 5c7c638 commit 743b052

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

bin/componentsjs-generator.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env node
2+
import * as fs from 'fs';
23
import * as Path from 'path';
34
import * as minimist from 'minimist';
45
import { GeneratorFactory } from '../lib/config/GeneratorFactory';
@@ -36,7 +37,17 @@ if (args.help) {
3637
showHelp();
3738
} else {
3839
const packageRootDirectories = (args._.length > 0 ? args._ : [ '' ])
39-
.map(path => Path.posix.join(process.cwd(), path));
40+
.map(path => Path.posix.join(process.cwd(), path))
41+
.flatMap(path => {
42+
// Since path expansion does not work on Windows, we may receive wildcard paths, so let's expand those here
43+
if (path.endsWith('*')) {
44+
path = path.slice(0, -1);
45+
// eslint-disable-next-line no-sync
46+
return fs.readdirSync(path)
47+
.map(subFile => Path.posix.join(path, subFile));
48+
}
49+
return path;
50+
});
4051
new GeneratorFactory({ resolutionContext: new ResolutionContext() })
4152
.createGenerator(process.cwd(), args, packageRootDirectories)
4253
.then(generator => generator.generateComponents())

0 commit comments

Comments
 (0)