@@ -24,13 +24,29 @@ function transformFileName(fileName) {
2424
2525gulp . task ( 'vectormap-utils' , function ( ) {
2626 return merge (
27- createVectorMapUtilsStream ( 'browser' , '.debug' , false ) ,
28- createVectorMapUtilsStream ( 'browser' , '' , true ) ,
29- createVectorMapUtilsStream ( 'node' , '' , false )
27+ createBrowserVectorMapUtilsStream ( '.debug' , false ) ,
28+ createBrowserVectorMapUtilsStream ( '' , true ) ,
3029 ) ;
3130} ) ;
3231
33- gulp . task ( 'vectormap-data' , gulp . series ( 'vectormap-utils' , function ( ) {
32+ function buildNodeUtilsForDataGeneration ( ) {
33+ const settings = require ( path . join ( '../..' , VECTORMAP_UTILS_PATH , '_settings.json' ) ) ;
34+ const part = settings [ 'node' ] ;
35+ return gulp . src ( settings . commonFiles . concat ( part . files ) . map ( transformFileName ) )
36+ . pipe ( concat ( part . fileName + '.js' ) )
37+ . pipe ( headerPipes . useStrict ( ) )
38+ . pipe ( gulp . dest ( VECTORMAP_UTILS_RESULT_PATH ) ) ;
39+ }
40+
41+ function cleanNodeUtils ( done ) {
42+ const nodeFile = path . join ( VECTORMAP_UTILS_RESULT_PATH , 'dx.vectormaputils.node.js' ) ;
43+ if ( fs . existsSync ( nodeFile ) ) {
44+ fs . unlinkSync ( nodeFile ) ;
45+ }
46+ done ( ) ;
47+ }
48+
49+ gulp . task ( 'vectormap-data' , gulp . series ( buildNodeUtilsForDataGeneration , function ( ) {
3450 const stream = merge ( ) ;
3551 const processFiles = require ( path . join ( '../..' , VECTORMAP_UTILS_RESULT_PATH , 'dx.vectormaputils.node.js' ) ) . processFiles ;
3652
@@ -57,7 +73,7 @@ gulp.task('vectormap-data', gulp.series('vectormap-utils', function() {
5773 } ) ;
5874 } ) ;
5975 return stream ;
60- } ) ) ;
76+ } , cleanNodeUtils ) ) ;
6177
6278function patchVectorMapUtilsStream ( stream , isMinify ) {
6379 return stream . pipe ( headerPipes . useStrict ( ) )
@@ -67,20 +83,17 @@ function patchVectorMapUtilsStream(stream, isMinify) {
6783 . pipe ( gulp . dest ( VECTORMAP_UTILS_RESULT_PATH ) ) ;
6884}
6985
70- function createVectorMapUtilsStream ( name , suffix , isMinify ) {
86+ function createBrowserVectorMapUtilsStream ( suffix , isMinify ) {
7187 const settings = require ( path . join ( '../..' , VECTORMAP_UTILS_PATH , '_settings.json' ) ) ;
72- const part = settings [ name ] ;
88+ const part = settings [ 'browser' ] ;
7389 const stream = gulp . src ( settings . commonFiles . concat ( part . files ) . map ( transformFileName ) )
7490 . pipe ( concat ( part . fileName + suffix + '.js' ) ) ;
7591
76- if ( name === 'browser' ) {
77- return stream . pipe ( tap ( file => {
78- patchVectorMapUtilsStream ( gulp . src ( 'build/gulp/vectormaputils-template.jst' )
79- . pipe ( template ( { data : file . contents } ) )
80- . pipe ( rename ( path . basename ( file . path ) ) ) , isMinify ) ;
81- } ) ) ;
82- }
83- return patchVectorMapUtilsStream ( stream , isMinify ) ;
92+ return stream . pipe ( tap ( file => {
93+ patchVectorMapUtilsStream ( gulp . src ( 'build/gulp/vectormaputils-template.jst' )
94+ . pipe ( template ( { data : file . contents } ) )
95+ . pipe ( rename ( path . basename ( file . path ) ) ) , isMinify ) ;
96+ } ) ) ;
8497}
8598
8699gulp . task ( 'vectormap' , gulp . series ( 'vectormap-utils' , 'vectormap-data' ) ) ;
0 commit comments