(require("auto-generate"))(filePath, name, content, options)
Writes given content as an auto generated part to file considering options.
Parameters:
| Name | Type | Description |
|---|---|---|
filePath |
string | File which content is written into |
name |
string | Name of the part. This is used for differentiating it from other auto generated content. |
content |
string | Content to write |
options |
genOptions | Options how part is generated. |
Example
var autogen = require('auto-generate');
var content = 'var someCode = "Joe";' // etc. auto generated code
autogen(path.join(__dirname, 'model', 'account.js'), 'model', content);
Type Definitions
-
genOptions
-
Options used to create auto generated part.
Type:
- Object
- Source:
Properties:
Name Type Description overWriteboolean If file already exists. Update the file.
overWriteEvenChangedboolean Overwrite generated part even it is modified manually.
backupboolean Create backup if a file is overwritten.
ignoreWhitespaceChangeboolean Assume it is unmodified if whitespace is modified when calculating digest.
ignoreCommentChangeboolean Assume it is unmodified if comment is changed when calculating digest. This also enables ignoreWhitespaceChange too.
atStartboolean Add text at the end of file. Otherwise it adds at the end. Either way replaces original text in place.