Engine to process multiple files with unified, allowing users to configure from the file-system.
The following projects wrap the engine:
- unified-args — Create CLIs for processors;
- unified-engine-gulp — Create Gulp plug-ins;
- unified-engine-atom — Create Atom Linters for processors.
npm:
npm install unified-engine
The following example processes all files in the current directory
with a markdown extension with remark, allows
configuration from .remarkrc
and package.json
files,
ignoring files from .remarkignore
files, and more.
var engine = require('unified-engine');
var remark = require('remark');
engine({
processor: remark,
globs: ['.'],
extensions: ['md', 'markdown', 'mkd', 'mkdn', 'mkdown'],
pluginPrefix: 'remark',
presetPrefix: 'remark-preset',
rcName: '.remarkrc',
packageField: 'remarkConfig',
ignoreName: '.remarkignore',
color: true
}, function (err) {
if (err) throw err;
});
Process files according to options
and invoke callback
when done.
processor
(Processor
) — Unified processor to transform files.cwd
(string
, default:process.cwd()
) — Directory to search files in, load plug-ins from, and more.globs
(Array.<string>
, optional) — Paths or globs to files and directories to process.extensions
(Array.<string>
, optional) — Ifglobs
matches directories, include files withextensions
streamIn
(ReadableStream
, default:process.stdin
) — Stream to read from if no files are found or given.filePath
(string
, optional) — File path to process the given file onstreamIn
as.streamOut
(WritableStream
, default:process.stdout
) — Stream to write processed files to.streamError
(WritableStream
, default:process.stderr
) — Stream to write the report (if any) to.out
(boolean
, default: depends) — Whether to write the processed file tostreamOut
.output
(boolean
orstring
, default:false
) — Whether to write successfully processed files, and where to.alwaysStringify
(boolean
, default:false
) — Whether to always compile successfully processed files.tree
(boolean
, default:false
) — Whether to treat both input and output as a syntax tree.treeIn
(boolean
, default:tree
) — Whether to treat input as a syntax tree.treeOut
(boolean
, default:tree
) — Whether to treat output as a syntax tree.rcName
(string
, optional) — Name of configuration files to load.packageField
(string
, optional) — Property at which configuration can be found inpackage.json
files.detectConfig
(boolean
, default: whetherrcName
orpackageField
is given) — Whether to search for configuration files.rcPath
(string
, optional) — File-path to a configuration file to load.settings
(Object
, optional) — Configuration for the parser and compiler of the processor.ignoreName
(string
, optional) — Name of ignore files to load.detectIgnore
(boolean
, default: whetherignoreName
is given) — Whether to search for ignore files.ignorePath
(string
, optional) — File-path to an ignore file to load.silentlyIgnore
(boolean
, default:false
) — Skip given files if they are ignored.plugins
(Object
, optional) — Map of plug-in names or paths to their options.presets
(Object
, optional) — Map of preset names or paths to their options.pluginPrefix
(string
, optional) — When given, optional prefix to use when searching for plug-ins.presetPrefix
(string
, optional) — When given, optional prefix to use when searching for presets.configTransform
(Function
, optional) — Transform config files from a different schema.injectedPlugins
(Array
, optional) — List of loaded plug-ins to use.color
(boolean
, default:false
) — Whether to report with ANSI colour sequences.silent
(boolean
, default:false
) — Report only fatal errors.quiet
(boolean
, default:silent
) — Do not report successful files.frail
(boolean
, default:false
) — Treat warnings as errors.files
(Array.<VFile>
, optional) — Use the given files (in addition to searching forglobs
).
Callback invoked when processing according to options
is complete.
Invoked with either a fatal error if processing went horribly wrong
(probably due to incorrect configuration), or a status code and the
processing context.
err
(Error
) — Fatal error.code
(number
) — Either0
, if successful, or1
, if unsuccessful. The latter occurs if fatal errors happen when processing individual files, or iffrail
is set and warnings occur.context
(Object
) — Processing context, containing internally used information and afiles
array with the processed files.
doc/plug-ins.md
describes in detail how plug-ins
can add more files to be processed and handle all transformed files.
doc/configure.md
describes in detail how configuration
files work.
doc/ignore.md
describes in detail how ignore files work.