Skip to content

Commit

Permalink
Merge d355b8d into 606d3cf
Browse files Browse the repository at this point in the history
  • Loading branch information
tadatuta committed Nov 25, 2016
2 parents 606d3cf + d355b8d commit 66df090
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
23 changes: 21 additions & 2 deletions api.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,28 @@ borschik

#### dependantFiles

Тип: `String[]`. По умолчанию: `[]`.
Тип: `String[]` или `Object`. По умолчанию: `[]`.

Имена файлов, после сборки которых запустится обработка исходного файла с помощью `borschik`
Имена файлов, после сборки которых запустится обработка исходного файла с помощью `borschik`.

Опция ожидает объект, где ключ это путь к ноде, а значение — массив файлов из указанной ноды.

```js
{
dependantFiles: {
'path/to/index': ['index.css', 'index.js'],
'path/to/keyboard': ['keyboard.css', 'keyboard.js']
}
}
```

Если переданы строки, то ожидается, что это имена таргетов текущей ноды:

```js
{
dependantFiles: ['index.css', 'index.js']
}
```

#### minify

Expand Down
20 changes: 17 additions & 3 deletions techs/borschik.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ module.exports = buildFlow.create()
.target('target')
.useSourceFilename('source')
.defineRequiredOption('source')
.useSourceListFilenames('dependantFiles')
.optionAlias('target', 'destTarget')
.optionAlias('source', 'sourceTarget')
.defineOption('minify', true)
.defineOption('freeze', true)
.defineOption('noCache', false)
.defineOption('tech', null)
.defineOption('techOptions', null)
.defineOption('dependantFiles', [])
.needRebuild(function () {
return this._noCache;
})
Expand All @@ -86,8 +86,22 @@ module.exports = buildFlow.create()
tech: this._tech,
techOptions: this._techOptions
},
jobQueue = this.node.getSharedResources().jobQueue;
jobQueue = this.node.getSharedResources().jobQueue,
sourcesByNodes = this._dependantFiles.reduce(function (acc, dependancy) {
if (typeof dependancy === 'object') {
return dependancy;
}

return jobQueue.push(modulePath, opts);
var nodePath = node.getPath();

acc[nodePath] || (acc[nodePath] = []);
acc[nodePath].push(dependancy);

return acc;
}, {});

return node.requireNodeSources(sourcesByNodes).then(function () {
return jobQueue.push(modulePath, opts);
});
})
.createTech();

0 comments on commit 66df090

Please sign in to comment.