gulpfile.js 1.08 KB
const { series, src, dest, } = require('gulp')
const babel = require('gulp-babel')
const removeUseStrict = require('gulp-remove-use-strict')
const exec = require('gulp-exec')
const del = require('del')
const path = require('path')


async function clean(cb) {
  await del(['dist'])
  await cb()
}

function complieFormat(cb) {
  src('./src/main/webapp/js/grapheditor/Format.js')
    .pipe(babel({ presets: ['@babel/env'] }))
    .pipe(removeUseStrict())
    .pipe(dest('./src/main/webapp/js/grapheditor'))

  cb()
}

function copyFile(cb) {
  src('./src/main/webapp/js/grapheditor/Format.js')
    .pipe(dest('./dist/Format_before_compile.js'))

  cb()
}

async function buildWar(cb) {
  await new Promise((resolve) => {
    src(path.resolve(__dirname, './'))
      .pipe(exec('cd etc/build && ant war', function (err) {
        resolve()
      }))
  })
}

function reductionFile(cb) {
  src(path.resolve(__dirname, './dist/Format_before_compile.js/Format.js'))
    .pipe(dest('./src/main/webapp/js/grapheditor'))
  cb()
}

exports.default = series(copyFile, complieFormat, buildWar, reductionFile, clean)