Module: auto-generate

Module: auto-generate

(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.

Source:
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
Properties:
Name Type Description
overWrite boolean

If file already exists. Update the file.

overWriteEvenChanged boolean

Overwrite generated part even it is modified manually.

backup boolean

Create backup if a file is overwritten.

ignoreWhitespaceChange boolean

Assume it is unmodified if whitespace is modified when calculating digest.

ignoreCommentChange boolean

Assume it is unmodified if comment is changed when calculating digest. This also enables ignoreWhitespaceChange too.

atStart boolean

Add text at the end of file. Otherwise it adds at the end. Either way replaces original text in place.

Source: