This repository was archived by the owner on Oct 2, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
78 lines (66 loc) · 1.99 KB
/
index.js
File metadata and controls
78 lines (66 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* global async:true */
/**
* Functions & Basic Needs.
* @type {string}
*/
const $vs_boilerplate_v = '1.4';
/**
* Required Imports.
*/
const { handler } = require( './handler' );
const $gulp = require( 'gulp' );
const { get_config } = require( './functions' );
$gulp.task( 'watch', ( callback ) => {
let $config = get_config();
async function processData( $id, $config, $global ) {
let $handler = new handler( $id, $config, $global );
await $handler.init();
}
async function watchArray( array, src = null ) {
for( let $id in array ) {
if( array.hasOwnProperty( $id ) ) {
if( array[ $id ] instanceof Array ) {
for( let $_c in array[ $id ] ) {
if( array[ $id ].hasOwnProperty( $_c ) ) {
let $watch = ( true === array[ $id ][ $_c ].watch ) ? $id : array[ $id ][ $_c ].watch;
$gulp.watch( $watch, { queue: true }, ( cb ) => {
await processData( $id, array[ $id ][ $_c ], $config.config ).then( () => cb() );
} );
}
}
} else {
let $watch = ( true === array[ $id ].watch ) ? $id : array[ $id ].watch;
$gulp.watch( $watch, { queue: true }, ( cb ) => {
await processData( $id, array[ $id ], $config.config ).then( () => cb() );
} );
}
}
}
}
if( typeof $config.files !== 'undefined' ) {
watchArray( $config.files ).then( () => {
callback();
} );
}
} );
$gulp.task( 'compile', ( callback ) => {
let $config = get_config();
async function processArray( array, src = null ) {
for( let $id in array ) {
if( array.hasOwnProperty( $id ) ) {
if( array[ $id ] instanceof Array ) {
await processArray( array[ $id ], $id );
} else {
let $_src = ( null === src ) ? $id : src;
let $handler = new handler( $_src, array[ $id ], $config.config );
await $handler.init();
}
}
}
}
if( typeof $config.files !== 'undefined' ) {
processArray( $config.files ).then( () => {
callback();
} );
}
} );