Skip to content

Commit

Permalink
Add force flag and corresponding documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JustMaier committed Nov 13, 2017
1 parent 6ee2839 commit f6fa6a4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ Plop comes with bypass logic built-in for standard inquirer prompts, but there a

If you have published a 3rd party inquirer prompt plugin and would like to support bypass functionality for plop users out of the box, that is covered in [another section of this documentation](#3rd-party-prompt-bypass).

### Force File Overwrite
By default Plop keeps your files safe by not overwriting destination files when running [`add`](#add) actions. If you're absolutely certain that you'd like to overwrite a files, you can append `--force` when running Plop from the terminal. If there are specific [`add`](#add) actions that you'd like to have the ability to always overwrite, set the `overwrite` property on that action to true.

## Why Generators?
Because when you create your boilerplate separate from your code, you naturally put more time and thought into it.

Expand Down Expand Up @@ -236,6 +239,8 @@ Method | Parameters | Returns | Description
**setPlopfilePath** | String | | set the `plopfilePath` value which is used internally to locate resources like template files
**getPlopfilePath** | | *String* | returns the absolute path to the plopfile in use
**getDestBasePath** | | *String* | returns the base path that is used when creating files
**setForce** | | *Boolean* | a way to set the value of `force` (useful for *[CustomAction](#-functionsignature-custom-action)*)
**getForce** | | *Boolean* | returns whether the [`--force`](#force-file-overwrite) flag was set or not
**setDefaultInclude** | *Object* | *Object* | sets the default config that will be used for this plopfile if it is consumed by another plopfile using `plop.load()`
**getDefaultInclude** | *String* | *Object* | gets the default config that will be used for this plopfile if it is consumed by another plopfile using `plop.load()`
**renderString** | String, Object | *String* | Runs the first parameter (*String*) through the handlebars template renderer using the second parameter (*Object*) as the data. Returns the rendered template.
Expand All @@ -251,6 +256,7 @@ Property | Type | Default | Description
**path** | *String* | | a handlebars template that (when rendered) is the path of the new file
**template** | *String* | | a handlebars template that should be used to build the new file
**templateFile** | *String* | | a path a file containing the `template`
**overwrite** | *Boolean* | false | overwrite if the file already exists
**abortOnFail** | | | *inherited from [ActionConfig](#-interface-actionconfig-)*

## AddMany
Expand All @@ -261,6 +267,7 @@ Property | Type | Default | Description
**destination** | *String* | | a handlebars template that (when rendered) is the destination folder for the new files
**base** | *String* | | the section of the path that should be excluded when adding files to the `destination` folder
**templateFiles** | *[Glob](https://github.com/sindresorhus/globby#globbing-patterns)* | | glob pattern that matches multiple template files to be added
**overwrite** | *Boolean* | false | overwrite if the file already exists
**abortOnFail** | | | *inherited from [ActionConfig](#-interface-actionconfig-)*

## Modify
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plop",
"version": "1.9.0",
"version": "1.9.1",
"description": "Micro-generator framework that makes it easy for an entire team to create files with a level of uniformity",
"main": "./src/plop.js",
"repository": {
Expand Down
4 changes: 3 additions & 1 deletion src/plop.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ function run(env) {
}

// set the default base path to the plopfile directory
const plop = nodePlop(plopfilePath);
const plop = nodePlop(plopfilePath, {
force: argv.force || argv.f
});
const generators = plop.getGeneratorList();
const generatorNames = generators.map(function (v) { return v.name; });

Expand Down

0 comments on commit f6fa6a4

Please sign in to comment.