Skip to content

Commit

Permalink
Merge 8f37d58 into 0944d1e
Browse files Browse the repository at this point in the history
  • Loading branch information
tadatuta committed Nov 20, 2016
2 parents 0944d1e + 8f37d58 commit 83ba241
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: ['a.css', 'a.js']
}
```

В случае передачи объекта, ключами является путь к ноде, а значениями — массив таргетов:

```js
{
dependantFiles: {
'path/to/node-1': ['a.css', 'a.js'],
'path/to/node-2': ['a.css', 'a.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 83ba241

Please sign in to comment.