-
Notifications
You must be signed in to change notification settings - Fork 0
actions
Stores and return the source root for this class. The source root is used to
prefix filepath with .read()
or .template()
.
- root - A string to resolve
sourceRoot
against.
Returns the source root value.
Sets the destination root for this class, the working directory.
Relatives path are added to the directory where the script was invoked and expanded.
This automatically creates the working directory if it doensn't exists and cd into it.
- root - A string to resolve
destinationRoot
against.
Returns the destinatio root value.
Make some of the file API aware of our source / destination root paths. copy, template (only when could be applied/required by legacy code), write and alike consider:
- source - the source path to be relative to generator's
templates/
directory. - destination - the destination path to be relative to application Gruntfile's directory (most likely cwd)
A simple method to read the content of the a file.
The encoding is utf8 by default, to read binary files, pass the proper encoding or null.
Non absolute path are prefixed by the source root.
- source - A filepath String to read from
- encoding - An optional encoding value to use (default: utf8)
Returns the file content
Writes a chunk of data to a given filepath
, checking for collision prior
to the file write.
- filepath - Path to write to
- conent - File content to write
Returns the generator instance
File collision checked. Takes a filepath
(the file about to be written)
and the actual content. A basic check is done to see if the file exists, it it does:
- read its content from FS
- compare it with content provided
- if identical, mark it as is and skip the check
- if diverged, prepare and show up the file collision menu
The menu has the following options:
- Y - yes, overwrite
- n - no, do not overwrite
- a - all, overwrite this and all others
- q - quit, abort
- d - diff, show the differences between the old and the new
- h - help, show this help
Use configured engine to render the provided source
template at the given
destination
. data
is an optional hash to pass to the template, if
undefined, executes the template in the generator instance context.
The engine method is the function used whenever a template needs to be rendered.
It uses the configured engine (default: underscore) to render the body
template with the provided data
.
- body - Template content
- data - Data to render the template with
Returns the rendered string
Copies recursively the files from source directory to root directory.
- source - Filepath of the directory to read from (relative to sourceRoot)
- destination - Filepath to copy to (relative to destinationRoot) Returns the generator instance
Remotely fetch a package on github, store this into a _cache folder, and provide a "remote" object as a facade API to ourself (part of genrator API, copy, template, directory)
Example:
this.remote('user', 'repo', function(err, remote) {
remote.copy('.', 'vendors/user-repo');
});
Returns the generator instance
Simple proxy to .copy(source, destination)
same as .template(source, destination, data)
same as .template(source, destination)
Runs npm
and bower
in the generated directory concurrently and prints a
message to let the user know.
Options:
- npm: bool, whether to run
npm install
, default: true - bower: bool, whether to run
bower install
, defaulkt: true - skipInstall: bool, whether to skip automatic installation and just print a message to the user how to do it, default: false
Example:
this.installDependencies({ bower: true, npm: true, skipInstall: false });
Returns the generator instance.