File: gulpfile.js

package info (click to toggle)
node-yarnpkg 1.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 92,980 kB
  • sloc: sh: 323; makefile: 19
file content (35 lines) | stat: -rw-r--r-- 971 bytes parent folder | download
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
'use strict';

const argv = require('yargs').argv;
const plumber = require('gulp-plumber');
const newer = require('gulp-newer');
const babel = require('gulp-babel');
const sourcemaps = require('gulp-sourcemaps');
const log = require('fancy-log');
const gulp = require('gulp');
const path = require('path');
const fs = require('fs');

const babelRc = JSON.parse(fs.readFileSync(path.join(__dirname, '.babelrc'), 'utf8'));

const ver = process.versions.node;
const majorVer = parseInt(ver.split('.')[0], 10);

const build = (lib, opts) =>
  gulp.src('src/**/*.js')
      .pipe(plumber({
        errorHandler(err) {
          log.error(err.stack);
        },
      }))
      .pipe(newer(lib))
      .pipe(sourcemaps.init())
      .pipe(babel(opts))
      .pipe(sourcemaps.write('.', {sourceRoot: '../src'}))
      .pipe(gulp.dest(lib));

gulp.task('build', () =>
  build('debian/lib', babelRc.env[majorVer >= 5 ? 'node5' : 'pre-node5'])
);

gulp.task('default', ['build']);