mirror of
https://github.com/bobwen-dev/react-templates
synced 2025-04-12 00:56:39 +02:00
fixed issue with globing pattern, allow glob pattern
This commit is contained in:
parent
3eb8df60b3
commit
6c5ea9e3a1
11
docs/cli.md
11
docs/cli.md
@ -7,7 +7,7 @@ npm install react-templates -g
|
||||
|
||||
## Usage
|
||||
```shell
|
||||
rt [file.rt|dir]* [options]
|
||||
rt [file.rt|glob]* [options]
|
||||
```
|
||||
|
||||
Such as:
|
||||
@ -15,6 +15,15 @@ Such as:
|
||||
rt dir/file.rt
|
||||
```
|
||||
|
||||
Please note that when passing a glob as a parameter, it will be expanded by your shell.
|
||||
The results of the expansion can vary depending on your shell, and its configuration.
|
||||
If you want to use node glob syntax, you have to quote your parameter (using double quotes if you need it to run in Windows), as follows:
|
||||
|
||||
|
||||
```shell
|
||||
rt 'src/**/*.rt'
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
The command line utility has several options. You can view the options by running `rt -h`.
|
||||
|
@ -35,6 +35,7 @@
|
||||
"css": "2.2.1",
|
||||
"escodegen": "1.8.1",
|
||||
"esprima": "3.1.3",
|
||||
"glob": "7.1.1",
|
||||
"lodash": "4.17.4",
|
||||
"normalize-html-whitespace": "0.2.0",
|
||||
"optionator": "0.8.2",
|
||||
|
16
src/cli.js
16
src/cli.js
@ -2,6 +2,7 @@
|
||||
'use strict';
|
||||
const _ = require('lodash');
|
||||
const path = require('path');
|
||||
// const fs = require('fs');
|
||||
const api = require('./api');
|
||||
const context = require('./context');
|
||||
const shell = require('./shell');
|
||||
@ -10,6 +11,7 @@ const options = require('./options');
|
||||
const reactDOMSupport = require('./reactDOMSupport');
|
||||
const reactTemplates = require('./reactTemplates');
|
||||
const rtStyle = require('./rtStyle');
|
||||
const glob = require('glob');
|
||||
|
||||
/**
|
||||
* @param {Options} currentOptions
|
||||
@ -31,7 +33,19 @@ function executeOptions(currentOptions) {
|
||||
} else if (currentOptions.listTargetVersion) {
|
||||
printVersions(currentOptions);
|
||||
} else if (files.length) {
|
||||
_.forEach(files, handleSingleFile.bind(this, currentOptions));
|
||||
// console.log(files);
|
||||
// console.log(files.length);
|
||||
// const allFiles = _.flatMap(files, f => {
|
||||
// const fp = path.resolve(context.cwd, f);
|
||||
// if (fs.statSync(fp).isDirectory()) {
|
||||
// // TODO: consider removing glob and simply walk the directory
|
||||
// return glob.sync(`${fp}/**/*.rt`, {cwd: context.cwd});
|
||||
// }
|
||||
// return fp;
|
||||
// });
|
||||
const allFiles = _.flatMap(files, f => glob.sync(f, {cwd: context.cwd}));
|
||||
// console.log(allFiles.length);
|
||||
_.forEach(allFiles, handleSingleFile.bind(this, currentOptions));
|
||||
ret = shell.printResults(context);
|
||||
} else {
|
||||
console.log(options.generateHelp());
|
||||
|
@ -24,7 +24,7 @@ module.exports = optionator({
|
||||
${pkg.description}
|
||||
|
||||
Usage:
|
||||
$ rt <filename> [<filename> ...] [<args>]`,
|
||||
$ rt <filename|glob> [<filename|glob> ...] [<args>]`,
|
||||
concatRepeatedArrays: true,
|
||||
mergeRepeatedObjects: true,
|
||||
options: [{
|
||||
|
Loading…
x
Reference in New Issue
Block a user