Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
"flowtype",
"prettier"
],
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": false
}
},
"rules": {
"prettier/prettier": [
"error",
Expand All @@ -28,6 +23,11 @@
"jsx-quotes": 0,
"react/jsx-filename-extension": "off"
},
"settings": {
"flowtype": {
"onlyFilesWithFlowAnnotation": false
}
},
"env": {
"es6": true,
"browser": true,
Expand All @@ -43,4 +43,4 @@
"React$Element": true,
"Generator": true
}
}
}
12 changes: 11 additions & 1 deletion content/docs/extensibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,21 @@ This means:

_Note:_ The current strategy when there are two or more `.hygen.js` files in the path upwards is to _take the first one_ and ignore the rest.

# Ignore Generators and actions
```javascript
// .hygen.js
module.exports = {
ignoredGenerators: ['wip'],
ignoredActions: ['utils'],
ignoredFiles: ['utils.js'],
}
```

# Helpers

Here's a template that uses a function that doesn't exist in the helper accessor `h`. This function is plainly called `extended`, for lack of a better name.

```yaml{5}
```
---
to: given/hygen-js/new.md
---
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@
"redux",
"react"
]
}
}
11 changes: 11 additions & 0 deletions src/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ Options:
process.exit(0)
}

if ((config.ignoredGenerators || []).includes(generator)) {
logger.log(`generator: ${generator} is ignored`)
throw new Error('please specify another generator')
}

if ((config.ignoredActions || []).includes(action)) {
logger.log(`generator: ${generator}`)
logger.log(` action: ${action} is ignored`)
throw new Error('please specify another action')
}

logger.log(args.dry ? '(dry mode)' : '')
if (!generator) {
throw new Error('please specify a generator.')
Expand Down
4 changes: 4 additions & 0 deletions src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ async function getFiles(dir) {
return Array.prototype.concat(...files)
}

/* wow,
this would need to be refactored into a different form
for ignoring generator actions files
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anithri Seems like you don't need to refactor completely. I think adding another filter before the internal prompt/index filter. Maybe adding a glob to regex library like globrex.

Then you wouldn't need ignore configuration for each type of thing, just ignore based on path.

Something like:

// user config
const config = {
	userIgnores: [
		'wip/**',
		'utils.js'
	]
}

// ...
const globrex = require('globrex');
const userIgnores = config.userIgnores.map(g => globrex(g))


// ...
.then(filter(f => !userIgnores.find(ig => ig.regex.test(f))))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might make more sense to just forget the glob syntax and support plain regex

const render = async (
args: any,
config: RunnerConfig,
Expand Down
3 changes: 3 additions & 0 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export type RunnerConfig = {
logger: Logger,
debug: boolean,
helpers: Object,
ignoredGenerators: Array<string>,
ignoredActions: Array<string>,
ignoredFiles: Array<string>,
createPrompter: () => Prompter
}

Expand Down