UNPKG

1.68 kBJavaScriptView Raw
1//-------------------------------------
2//-- Local
3//-------------------------------------
4'use strict';
5
6// const debug = require('gulp-debug');
7const gulp = require('gulp');
8const env = require('~/helpers/env');
9const flow = require('~/helpers/flow');
10const paths = require('~/helpers/paths');
11const toolbox = require('~/helpers/toolbox');
12const util = require('~/helpers/util');
13
14
15module.exports = () => {
16
17 //-- Convert constants to JSON
18 flow.createTask('local-constants', ({ taskName }) => {
19 const streams = [];
20
21 for (const name of Object.keys(env.bundles)) {
22 const bundle = env.bundles[name];
23
24 const data = {
25 GENERATION: util.getGeneratedBanner(name, 'text'),
26 [env.id]: env.workflowConfig.version,
27 project: env.packageConfig.name,
28 bundle: name,
29 konstan: util.parseKonstan('local', name, bundle.output)
30 };
31
32 /* eslint-disable function-paren-newline */
33 streams.push(
34 toolbox.vinylStream(paths.filename.konstanLocal, JSON.stringify(data, null, 2))
35 .pipe(toolbox.plumber())
36 .pipe(gulp.dest(`${paths.directory.root}/${bundle.output.konstan}`))
37 .on('finish', () => {
38 toolbox.log(taskName, `'${bundle.output.konstan}/${paths.filename.konstanLocal}' written`, toolbox.filesize(`${paths.directory.root}/${bundle.output.konstan}/${paths.filename.konstanLocal}`));
39 })
40 );
41 /* eslint-enable function-paren-newline */
42 }
43
44 return toolbox.mergeStreams(streams);
45 });
46
47
48
49
50
51
52 //-- Rebuild
53 flow.createSequence('local', gulp.series('local-constants'), {
54 cleanBundle: ({ bundle }) => {
55 return [`${paths.directory.root}/${bundle.output.konstan}/${paths.filename.konstanLocal}`];
56 }
57 });
58
59};