1
1
import dotconfig from '@dotenvx/dotenvx'
2
2
import { deleteAsync } from 'del'
3
- import fs from 'fs'
4
3
import { dest , series , src , watch } from 'gulp'
5
4
import eslint from 'gulp-eslint-new'
6
5
import ts from 'gulp-typescript'
6
+ import prettier from 'gulp-prettier'
7
+ import minify from 'gulp-minify'
7
8
8
9
dotconfig . config ( )
9
10
@@ -13,14 +14,14 @@ dotconfig.config()
13
14
* Different paths we use...
14
15
*/
15
16
const paths = {
16
- src : './src' ,
17
- dist : './dist' ,
18
-
19
- /**
20
- * ACARS scripts/config directory. This, by default, points to the home directory
21
- * But you can change this to point to a local directory
22
- */
23
- acars : process . env . ACARS_SCRIPTS_PATH ,
17
+ src : './src' ,
18
+ dist : './dist' ,
19
+
20
+ /**
21
+ * ACARS scripts/config directory. This, by default, points to the home directory
22
+ * But you can change this to point to a local directory
23
+ */
24
+ acars : process . env . ACARS_SCRIPTS_PATH ,
24
25
}
25
26
26
27
/**
@@ -29,16 +30,31 @@ const paths = {
29
30
const tsProject = ts . createProject ( 'tsconfig.json' )
30
31
31
32
function build_ts ( ) {
32
- return tsProject . src ( )
33
- . pipe ( eslint ( ) )
34
- . pipe ( eslint . failAfterError ( ) )
35
- . pipe ( tsProject ( ) )
36
- . js . pipe ( dest ( paths . dist ) )
33
+ let pipeline = tsProject . src ( )
34
+ . pipe ( eslint ( ) )
35
+ . pipe ( eslint . failAfterError ( ) )
36
+ . pipe ( tsProject ( ) )
37
+ . js
38
+ . pipe ( prettier ( ) )
39
+
40
+ // Minify/mangle output
41
+ /*
42
+ pipeline = pipeline.pipe(minify({
43
+ mangle: false,
44
+ }))*/
45
+
46
+ pipeline = pipeline . pipe ( dest ( paths . dist ) )
47
+
48
+ return pipeline
37
49
}
38
50
51
+ /**
52
+ *
53
+ * @returns {* }
54
+ */
39
55
function copy_package ( ) {
40
- return src ( [ paths . src + '/package.json' ] )
41
- . pipe ( dest ( paths . dist ) )
56
+ return src ( [ paths . src + '/package.json' ] )
57
+ . pipe ( dest ( paths . dist ) )
42
58
}
43
59
44
60
/**
@@ -51,22 +67,22 @@ export const build = series(build_ts, copy_package)
51
67
*
52
68
*/
53
69
export function copy ( ) {
54
- console . log ( `Copying files to ${ paths . acars } ` )
70
+ console . log ( `Copying files to ${ paths . acars } ` )
55
71
56
- return src ( [ './**/*' , '!node_modules/**/*' ] , { 'cwd' : paths . dist } )
57
- . pipe ( dest ( paths . acars ) )
72
+ return src ( [ './**/*' , '!node_modules/**/*' ] , { 'cwd' : paths . dist } )
73
+ . pipe ( dest ( paths . acars ) )
58
74
}
59
75
60
76
/**
61
77
* The build steps that run from the csproj
62
78
* Force the output path to go into our build directory
63
79
*/
64
80
export const csbuild = series (
65
- async ( ) => {
66
- paths . acars = '../Content/config/default'
67
- } ,
68
- build ,
69
- copy ,
81
+ async ( ) => {
82
+ paths . acars = '../Content/config/default'
83
+ } ,
84
+ build ,
85
+ copy ,
70
86
)
71
87
72
88
/**
@@ -80,26 +96,26 @@ function build_dist() {
80
96
* Build a distribution zip file, which can be easily uploaded
81
97
*/
82
98
export const dist = series (
83
- build ,
84
- build_dist ,
99
+ build ,
100
+ build_dist ,
85
101
)
86
102
87
103
/**
88
104
* Watch the src folder for updates, compile them and then copy them
89
105
* to the config directory. ACARS should auto-reload
90
106
*/
91
107
export async function testing ( ) {
92
- watch ( 'src/' , {
93
- ignoreInitial : false ,
94
- delay : 500 ,
95
- } , series ( build , copy ) )
108
+ watch ( 'src/' , {
109
+ ignoreInitial : false ,
110
+ delay : 500 ,
111
+ } , series ( build , copy ) )
96
112
}
97
113
98
114
/**
99
115
* Watch the files and distribute them out
100
116
*/
101
117
export function watchFiles ( ) {
102
- watch ( 'src/' , build )
118
+ watch ( 'src/' , build )
103
119
}
104
120
105
121
export { watchFiles as watch }
@@ -108,12 +124,12 @@ export { watchFiles as watch }
108
124
* Clean up the /dest directory
109
125
*/
110
126
export async function clean ( ) {
111
- try {
112
- await deleteAsync ( [ paths . dist ] )
113
- await Promise . resolve ( )
114
- } catch ( e ) {
115
- console . log ( e )
116
- }
127
+ try {
128
+ await deleteAsync ( [ paths . dist ] )
129
+ await Promise . resolve ( )
130
+ } catch ( e ) {
131
+ console . log ( e )
132
+ }
117
133
}
118
134
119
135
/**
0 commit comments