From 600d748236de20c690260d08f788e617761dbd23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 27 Dec 2018 14:11:07 +0100 Subject: [PATCH] remove usage of babel, replace import with require MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- .babelrc | 11 ----------- gulpfile.js | 14 ++------------ package.json | 15 +-------------- src/app.js | 14 +++++++------- src/builds.js | 8 ++++---- src/comments.js | 6 +++--- src/schema.js | 2 +- src/server.js | 12 ++++++------ test/app.js | 14 +++++++------- test/comments.js | 10 +++++----- test/schema.js | 10 +++++----- test/setup.js | 8 ++++---- 12 files changed, 45 insertions(+), 79 deletions(-) delete mode 100644 .babelrc diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 3c8daf6..0000000 --- a/.babelrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "env": { - "test": { - "plugins": [ "istanbul" ] - } - }, - "presets": [ - ["@babel/env", { "targets": {"node": "current"} }] - ], - "plugins": ["@babel/plugin-transform-async-to-generator"] -} diff --git a/gulpfile.js b/gulpfile.js index 3796d1a..62ae5f3 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,4 @@ const gulp = require('gulp') -const babel = require('gulp-babel') const clean = require('gulp-clean') const mocha = require('gulp-mocha') const print = require('gulp-print').default @@ -10,7 +9,6 @@ gulp.task('devel', () => { nodemon({ script: 'src/server.js', presets: ['env', 'stage-2'], - exec: 'babel-node' }) .on('restart', () => { console.log('>> node restart') }) }) @@ -21,24 +19,16 @@ gulp.task('clean', () => gulp.task('test', () => gulp.src('test/**/*.js', {read: false}) - .pipe(mocha({ - reporter: 'list', - require: '@babel/register', - })) + .pipe(mocha({reporter: 'list'})) ) gulp.task('testw', () => gulp.src('test/**/*.js', {read: false}) - .pipe(mocha({ - reporter: 'list', - require: '@babel/register', - watch: true, - })) + .pipe(mocha({reporter: 'list', watch: true})) ) gulp.task('build', ['clean', 'test'], () => gulp.src('src/**/*.js') - .pipe(babel()) .pipe(print()) .pipe(gulp.dest('dist/')) ) diff --git a/package.json b/package.json index 3906905..d0fd057 100644 --- a/package.json +++ b/package.json @@ -18,22 +18,15 @@ "lokijs": "^1.5.5" }, "devDependencies": { - "@babel/cli": "^7.1.2", - "@babel/core": "^7.1.2", - "@babel/node": "^7.0.0", - "@babel/plugin-transform-async-to-generator": "^7.1.0", - "@babel/preset-env": "^7.1.0", - "babel-core": "^7.0.0-bridge.0", - "babel-plugin-istanbul": "^5.1.0", "chai": "^4.2.0", "chai-as-promised": "^7.1.1", "gulp": "^3.9.1", - "gulp-babel": "^8.0.0-beta.2", "gulp-clean": "^0.4.0", "gulp-exec": "^3.0.2", "gulp-mocha": "^6.0.0", "gulp-nodemon": "^2.2.1", "gulp-print": "^5.0.0", + "gulp-run-command": "^0.0.9", "mocha": "^5.2.0", "nodemon": "^1.18.4", "nyc": "^13.1.0", @@ -53,12 +46,6 @@ "push": "gulp push", "release": "release" }, - "mocha": [ - "@babel/register" - ], - "require": [ - "@babel/register" - ], "keywords": [ "github", "comments", diff --git a/src/app.js b/src/app.js index 0a8e2a6..ac1b8ef 100644 --- a/src/app.js +++ b/src/app.js @@ -1,10 +1,10 @@ -import log from 'loglevel' -import Koa from 'koa' -import JSON from 'koa-json' -import Logger from 'koa-logger' -import JsonError from 'koa-json-error' -import JoiRouter from 'koa-joi-router' -import BodyParser from 'koa-bodyparser' +const log = require('loglevel') +const Koa = require('koa') +const JSON = require('koa-json') +const Logger = require('koa-logger') +const JsonError = require('koa-json-error') +const JoiRouter = require('koa-joi-router') +const BodyParser = require('koa-bodyparser') const App = (ghc) => { const app = new Koa() diff --git a/src/builds.js b/src/builds.js index 7a0c820..1985dc3 100644 --- a/src/builds.js +++ b/src/builds.js @@ -1,7 +1,7 @@ -import log from 'loglevel' -import Joi from 'joi' -import Loki from 'lokijs' -import schema from './schema' +const log = require('loglevel') +const Joi = require('joi') +const Loki = require('lokijs') +const schema = require('./schema') class Builds { constructor(path, interval) { diff --git a/src/comments.js b/src/comments.js index d8ae05e..6dffe84 100644 --- a/src/comments.js +++ b/src/comments.js @@ -1,6 +1,6 @@ -import log from 'loglevel' -import Handlebars from 'handlebars' -import template from './template' +const log = require('loglevel') +const Handlebars = require('handlebars') +const template = require('./template') /* in theory the jenkins build comment should be the first one */ const PER_PAGE = 100 diff --git a/src/schema.js b/src/schema.js index 8dbf6d3..1264ec2 100644 --- a/src/schema.js +++ b/src/schema.js @@ -1,4 +1,4 @@ -import Joi from 'joi' +const Joi = require('joi') const schema = Joi.object().keys({ id: Joi.alternatives().try(Joi.number().positive(), Joi.string()).required(), diff --git a/src/server.js b/src/server.js index f24ab36..df76130 100644 --- a/src/server.js +++ b/src/server.js @@ -1,10 +1,10 @@ -import log from 'loglevel' -import Logger from 'koa-logger' -import Octokit from '@octokit/rest' +const log = require('loglevel') +const Logger = require('koa-logger') +const Octokit = require('@octokit/rest') -import App from './app' -import Builds from './builds' -import Comments from './comments' +const App = require('./app') +const Builds = require('./builds') +const Comments = require('./comments') /* DEFAULTS */ const LOG_LEVEL = process.env.LOG_LEVEL || 'INFO' diff --git a/test/app.js b/test/app.js index f18fce9..5d6c1ca 100644 --- a/test/app.js +++ b/test/app.js @@ -1,11 +1,11 @@ -import { expect } from 'chai' -import sinon from 'sinon' -import request from 'supertest' +const expect = require('chai').expect +const sinon = require('sinon') +const request = require('supertest') -import sample from './sample' -import App from '../src/app' -import Builds from '../src/builds' -import Comments from '../src/comments' +const sample = require('./sample') +const App = require('../src/app') +const Builds = require('../src/builds') +const Comments = require('../src/comments') let ghc, app diff --git a/test/comments.js b/test/comments.js index ca71ad6..de185b0 100644 --- a/test/comments.js +++ b/test/comments.js @@ -1,9 +1,9 @@ -import { expect } from 'chai' -import sinon from 'sinon' +const expect = require('chai').expect +const sinon = require('sinon') -import sample from './sample' -import Builds from '../src/builds' -import Comments from '../src/comments' +const sample = require('./sample') +const Builds = require('../src/builds') +const Comments = require('../src/comments') let comments, client, builds diff --git a/test/schema.js b/test/schema.js index 9270279..558d43f 100644 --- a/test/schema.js +++ b/test/schema.js @@ -1,9 +1,9 @@ -import { expect } from 'chai' -import sinon from 'sinon' -import Joi from 'joi' +const expect = require('chai').expect +const sinon = require('sinon') +const Joi = require('joi') -import sample from './sample' -import Schema from '../src/schema' +const sample = require('./sample') +const Schema = require('../src/schema') let build diff --git a/test/setup.js b/test/setup.js index 37c73f7..3f3fec3 100644 --- a/test/setup.js +++ b/test/setup.js @@ -1,7 +1,7 @@ -import log from 'loglevel' -import chai from 'chai' -import sinonChai from 'sinon-chai' -import chaiAsPromised from 'chai-as-promised' +const log = require('loglevel') +const chai = require('chai') +const sinonChai = require('sinon-chai') +const chaiAsPromised = require('chai-as-promised') /* limit amount of console noise for tests */ log.setDefaultLevel(log.levels.WARN)