Generate an .babelrc file for babel in the current working directory or specified --dest.
npm install generate-babelrcGenerate an .babelrc file for babel in the current working directory or specified --dest.
  
 
- What is "Generate"?
- Command line usage
* Install
* Run
* Help
- CLI Usage
* Running tasks
* Available tasks
- API usage
* Install locally
* Use as a plugin
* Register as a generator
- Customization
* Destination directory
* Overriding templates
- About
* Related projects
* Contributing
* Running tests
* License
_(TOC generated by verb using markdown-toc)_
Generate is a command line tool and developer framework for scaffolding out new GitHub projects using generators and tasks. Answers to prompts and the user's environment can be used to determine the templates, directories, files and contents to build. Support for gulp, base and assemble plugins, and much more.
For more information about Generate:
* Visit the generate project
* Visit the generate documentation
* Find generators on npm (help us author generators)
Installing the CLI
To run the babelrc generator from the command line, you'll need to install generate globally first. You can do that now with the following command:
``sh`
$ npm install --global generate
This adds the gen command to your system path, allowing it to be run from any directory.
Install generate-babelrc
You may now install this module with the following command:
`sh`
$ npm install --global generate-babelrc
You should now be able to run generate-babelrc with the following command:
`sh`
$ gen babelrc
What will happen?
Running $ gen babelrc will run the generator's default task, which will:
1. prompt you for any information that's missing
2. render the necessary template(s) using your answers
3. write the resulting files to the current working directory
What you should see in the terminal
If completed successfully, you should see both starting and finished events in the terminal, like the following:
`sh`
[00:44:21] starting ...
...
[00:44:22] finished ✔
If you do not see one or both of those events, please let us know about it.
To see a general help menu and available commands for Generate's CLI, run:
`sh`
$ gen help
Tasks on generate-babelrc are run by passing the name of the task to run after the generator name, delimited by a comma:
`sh`
$ gen babelrc:foo
^ ^
generator task
Example
The following will run generator foo, task bar:
`sh`
$ gen foo:bar
Default task
When a task name is not explicitly passed on the command line, Generate's CLI will run the default task.
#### babelrc
Generate an .babelrc file to the current working directory.
Example
`sh`
$ gen babelrc
$ gen babelrc --dest ./docs
Visit Generate's documentation for tasks.
Use generate-babelrc as a plugin in your own generator.
Install with npm:
`sh`
$ npm install --save generate-babelrc
When used as a plugin, tasks from generate-babelrc are added to your generator's instance.
`js`
module.exports = function(app) {
app.use(require('generate-babelrc'));
// do generator stuff
};
Running tasks
You can now run any tasks from generate-babelrc as if they were part of your own generator.
`js
module.exports = function(app) {
app.use(require('generate-babelrc'));
app.task('foo', function(cb) {
// do task stuff
cb();
});
// run the mit task from generate-babelrc`
app.task('default', ['foo', 'mit']);
};
When registered as a generator, tasks from generate-babelrc are added to the "namespace" you give to the generator.
`js`
module.exports = function(app) {
app.register('foo', require('generate-babelrc'));
// generate
};
Running tasks
Pass the names of one or more tasks to run to the .generate method, prefixed with the namespace of the sub-generator (foo, in our example):
Examples
Run the bar task from generator foo:
`js
module.exports = function(app) {
app.register('foo', require('generate-babelrc'));
app.generate('foo:bar', function(err) {
if (err) console.log(err);
});
};
`
Wrap the call to .generate in a task, so it can be called on demand:
`js
module.exports = function(app) {
app.register('foo', require('generate-babelrc'));
app.task('bar', function(cb) {
app.generate('foo:bar', cb);
});
};
`
More information
Visit the generator docs to learn more about creating, installing, using and publishing generators.
The following instructions can be used to override settings in generate-babelrc. Visit the Generate documentation to learn about other ways to override defaults.
To customize the destination directory, install generate-dest globally, then in the command line prefix dest before any other generator names.
For example, the following will prompt you for the destination path to use, then pass the result to generate-babelrc:
`sh`
$ gen dest babelrc
You can override a template by adding a template of the same name to the templates directory in user home.
For example, to override the foo.tmp template, add a template at the following path ~/generate/generate-babelrc/templates/foo.tmpl, where ~/ is the user-home directory that os.homedir() resolves to on your system.
* babel: Turn ES6 code into readable vanilla ES5 with source maps | homepage
* generate: Command line tool and developer framework for scaffolding out new GitHub projects. Generate offers the… more | homepage
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Install dev dependencies:
`sh``
$ npm install -d && npm test
Copyright © 2016, Aurelien Verla.
Released under the MIT license.
*
_This file was generated by verb, v0.9.0, on July 17, 2016._