EN RU
Forum

Methodology

Technology

Toolbox

Libraries

Tutorials

Technologies for working with files

All technologies included in the ENB package are located in the techs package folder. They are connected from the make file using require('enb/techs/<tech-name>').

Example:

require('enb/techs/js')

To connect the technology to the node, specify the class and options (not required):

nodeConfig.addTech([ require('enb/techs/<tech-name>'), {/* [options] */} ]);

Without options:

nodeConfig.addTech(require('enb/techs/<tech-name>'));

To create copies of technologies for each language installed for the node or for the project (if languages for the node aren't specified), specify the {lang} substring in the technology options.

Example:

nodeConfig.setLanguages(['ru', 'en', 'tk']);nodeConfig.addTech([require('js-i18n'), { target: '?.{lang}.js', lang: '{lang}' }]);

Equivalent to:

nodeConfig.addTech([require('js-i18n'), { target: '?.ru.js', lang: 'ru' }]);
nodeConfig.addTech([require('js-i18n'), { target: '?.en.js', lang: 'en' }]);
nodeConfig.addTech([require('js-i18n'), { target: '?.tk.js', lang: 'tk' }]);

Technologies

file-copy

Copies one target to another. You can use it to build _?.css from ?.css for development mode.

Options

Example

nodeConfig.addTech([ require('enb/techs/file-copy'), {
  source: '?.css',
  target: '_?.css'
} ]);

file-merge

Joins a set of files into one file.

Options

Example

nodeConfig.addTech([ require('enb/techs/file-merge'), {
    sources: ['?.bemhtml', '?.pre.js']
    target: '?.js'
} ]);

file-provider

Provides an existing file for the make platform. You can use it to provide the original bemdeclfile.

Options

Example

nodeConfig.addTech([ require('enb/techs/file-provider'), { target: '?.bemdecl.js' } ]);

symlink

Creates a symlink from one target to another. You can use it to build _?.css from ?.css for development mode.

Options

Example

nodeConfig.addTech([ require('enb/techs/symlink'), {
  fileTarget: '?.css',
  symlinkTarget: '_?.css'
} ]);

write-file

Saves the target file in the file system.

Options

Example

Generating a text file

nodeConfig.addTech([ require('enb/techs/write-file'), {
    content: 'bla bla bla',
    fileOptions: {
        encoding: 'utf8', // default
        mode: '0o666', // default
        flag: 'w' //default
        },
    target: '?.bla.txt'
} ]);

Generating the bemdecl file

nodeConfig.addTech([ require('enb/techs/write-file'), {
    content: 'exports.blocks = {name: "bla"}',
    fileOptions: {
        encoding: 'utf8', // default
        mode: '0o666', // default
        flag: 'w' //default
        },
    target: '?.bemdecl.js'
} ]);