11import dotconfig from '@dotenvx/dotenvx'
22import { deleteAsync } from 'del'
3- import fs from 'fs'
43import { dest , series , src , watch } from 'gulp'
54import eslint from 'gulp-eslint-new'
65import ts from 'gulp-typescript'
6+ import prettier from 'gulp-prettier'
7+ import minify from 'gulp-minify'
78
89dotconfig . config ( )
910
@@ -13,14 +14,14 @@ dotconfig.config()
1314 * Different paths we use...
1415 */
1516const 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 ,
2425}
2526
2627/**
@@ -29,16 +30,31 @@ const paths = {
2930const tsProject = ts . createProject ( 'tsconfig.json' )
3031
3132function 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
3749}
3850
51+ /**
52+ *
53+ * @returns {* }
54+ */
3955function 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 ) )
4258}
4359
4460/**
@@ -51,22 +67,22 @@ export const build = series(build_ts, copy_package)
5167 *
5268 */
5369export function copy ( ) {
54- console . log ( `Copying files to ${ paths . acars } ` )
70+ console . log ( `Copying files to ${ paths . acars } ` )
5571
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 ) )
5874}
5975
6076/**
6177 * The build steps that run from the csproj
6278 * Force the output path to go into our build directory
6379 */
6480export 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 ,
7086)
7187
7288/**
@@ -80,26 +96,26 @@ function build_dist() {
8096 * Build a distribution zip file, which can be easily uploaded
8197 */
8298export const dist = series (
83- build ,
84- build_dist ,
99+ build ,
100+ build_dist ,
85101)
86102
87103/**
88104 * Watch the src folder for updates, compile them and then copy them
89105 * to the config directory. ACARS should auto-reload
90106 */
91107export 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 ) )
96112}
97113
98114/**
99115 * Watch the files and distribute them out
100116 */
101117export function watchFiles ( ) {
102- watch ( 'src/' , build )
118+ watch ( 'src/' , build )
103119}
104120
105121export { watchFiles as watch }
@@ -108,12 +124,12 @@ export { watchFiles as watch }
108124 * Clean up the /dest directory
109125 */
110126export 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+ }
117133}
118134
119135/**
0 commit comments