unified-engine
Engine to process multiple files with unified, allowing users to configure from the file-system.
Projects
The following projects wrap the engine:
unified-args
— Create CLIs for processorsunified-engine-gulp
— Create Gulp plug-insunified-engine-atom
— Create Atom Linters for processors
Installation
npm:
npm install unified-engine
Usage
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,
files: ['.'],
extensions: ['md', 'markdown', 'mkd', 'mkdn', 'mkdown'],
pluginPrefix: 'remark',
rcName: '.remarkrc',
packageField: 'remarkConfig',
ignoreName: '.remarkignore',
color: true
}, function (err) {
if (err) throw err;
});
Table of Contents
API
engine(options, callback)
Process files according to options
and invoke callback
when done.
options
processor
(Processor
) — Unified processor to transform filescwd
(string
, default:process.cwd()
) — Directory to search files in, load plug-ins from, and morefiles
(Array.<string|VFile>
, optional) — Paths or globs to files and directories, or virtual files, to processextensions
(Array.<string>
, optional) — Iffiles
matches directories, include files withextensions
streamIn
(ReadableStream
, default:process.stdin
) — Stream to read from if no files are found or givenfilePath
(string
, optional) — File path to process the given file onstreamIn
asstreamOut
(WritableStream
, default:process.stdout
) — Stream to write processed files tostreamError
(WritableStream
, default:process.stderr
) — Stream to write the report (if any) toout
(boolean
, default: depends) — Whether to write the processed file tostreamOut
output
(boolean
orstring
, default:false
) — Whether to write successfully processed files, and where toalwaysStringify
(boolean
, default:false
) — Whether to always compile successfully processed filestree
(boolean
, default:false
) — Whether to treat both input and output as a syntax treetreeIn
(boolean
, default:tree
) — Whether to treat input as a syntax treetreeOut
(boolean
, default:tree
) — Whether to treat output as a syntax treercName
(string
, optional) — Name of configuration files to loadpackageField
(string
, optional) — Property at which configuration can be found inpackage.json
filesdetectConfig
(boolean
, default: whetherrcName
orpackageField
is given) — Whether to search for configuration filesrcPath
(string
, optional) — File-path to a configuration file to loadsettings
(Object
, optional) — Configuration for the parser and compiler of the processorignoreName
(string
, optional) — Name of ignore files to loaddetectIgnore
(boolean
, default: whetherignoreName
is given) — Whether to search for ignore filesignorePath
(string
, optional) — File-path to an ignore file to loadsilentlyIgnore
(boolean
, default:false
) — Skip given files if they are ignoredplugins
(Object
, optional) — Map of plug-in names or paths to their optionspluginPrefix
(string
, optional) — When given, optional prefix to use when searching for plug-insconfigTransform
(Function
, optional) — Transform config files from a different schemareporter
(string
orfunction
, default:require('vfile-reporter')
) — Reporter to usereporterOptions
(Object?
, optional) — Config to pass to the used reportercolor
(boolean
, default:false
) — Whether to report with ANSI colour sequencessilent
(boolean
, default:false
) — Report only fatal errorsquiet
(boolean
, default:silent
) — Do not report successful filesfrail
(boolean
, default:false
) — Call back with an unsuccessful (1
) code on warnings as well as errors
function callback(err[, code, context])
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.
Parameters
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.
Plug-ins
doc/plug-ins.md
describes in detail how plug-ins
can add more files to be processed and handle all transformed files.
Configuration
doc/configure.md
describes in detail how configuration
files work.
Ignoring
doc/ignore.md
describes in detail how ignore files work.