Skip to content

Commit

Permalink
Update to es6+.
Browse files Browse the repository at this point in the history
Remove support for node 8.

Update dependencies.

Update eslint config.
  • Loading branch information
jonkemp committed Jan 20, 2020
1 parent 5998f80 commit 1086895
Show file tree
Hide file tree
Showing 7 changed files with 573 additions and 116 deletions.
26 changes: 16 additions & 10 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
},
"globals": {},
"extends": "eslint:recommended",

// Stop ESLint from looking for a configuration file in parent folders
"root": true,

"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "script",
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"rules": {
"block-scoped-var": 2,
"complexity": [
Expand Down Expand Up @@ -42,11 +54,6 @@
"never"
],

"strict": [
2,
"global"
],

"no-shadow": 2,
"no-use-before-define": 2,

Expand Down Expand Up @@ -124,14 +131,14 @@
],
"new-cap": 2,
"new-parens": 2,
"newline-after-var": [
1,
"always"
"padding-line-between-statements": [
"error",
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*"},
{ "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"]}
],
"no-array-constructor": 2,
"no-bitwise": 1,
"no-lonely-if": 1,
"no-multi-spaces": 1,
"no-multiple-empty-lines": 1,
"no-new-object": 2,
"no-spaced-func": 1,
Expand All @@ -141,7 +148,6 @@
1,
"always"
],
"one-var": 1,
"operator-assignment": [
1,
"always"
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ language: node_js
node_js:
- '12'
- '10'
- '8'

# whitelist
branches:
Expand Down
41 changes: 18 additions & 23 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
/* eslint-disable */
'use strict';

var gulp = require('gulp'),
eslint = require('gulp-eslint'),
mocha = require('gulp-mocha'),
qunit = require('./index'),
paths = {
scripts: ['./*.js', '!./gulpfile.js']
};

gulp.task('lint', function () {
return gulp.src(paths.scripts)
.pipe(eslint())
.pipe(eslint.format());
});
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const mocha = require('gulp-mocha');
const qunit = require('./index');

gulp.task('test', function () {
return gulp.src('./test/*.js')
.pipe(mocha());
});
const paths = {
scripts: ['./*.js', '!./gulpfile.js']
};

gulp.task('lint', () => gulp.src(paths.scripts)
.pipe(eslint({fix: true}))
.pipe(eslint.format()));

gulp.task('test', () => gulp.src('./test/*.js')
.pipe(mocha()));

gulp.task('qunit:pass', function () {
gulp.task('qunit:pass', () => {
qunit('./test/fixtures/passing.html');
});

gulp.task('qunit:fail', function () {
gulp.task('qunit:fail', () => {
qunit('./test/fixtures/failing.html');
});

gulp.task('qunit-verbose', function () {
gulp.task('qunit-verbose', () => {
qunit('./test/fixtures/passing.html', { 'verbose': true });
});

gulp.task('watch', function () {
gulp.task('watch', () => {
gulp.watch(paths.scripts, gulp.parallel('lint', 'test'));
});

Expand Down
56 changes: 25 additions & 31 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
'use strict';

var path = require('path'),
chalk = require('chalk'),
childProcess = require('child_process'),
phantomjs = require('phantomjs-prebuilt'),
binPath = phantomjs.path,
phantomjsRunnerDir = path.dirname(require.resolve('qunit-phantomjs-runner')),
isUrl = function (uri) {
return uri.match(/^http(s?):/) !== null;
};

module.exports = function (uri, options, callback) {
var opt = options || {},
cb = callback || function () {},
runner = path.join(phantomjsRunnerDir, 'runner-json.js'),
testUri = isUrl(uri) ? uri : 'file:///' + path.resolve(uri).replace(/\\/g, '/'),
childArgs = [],
proc;
const path = require('path');
const chalk = require('chalk');
const childProcess = require('child_process');
const phantomjs = require('phantomjs-prebuilt');
const binPath = phantomjs.path;
const phantomjsRunnerDir = path.dirname(require.resolve('qunit-phantomjs-runner'));
const isUrl = uri => uri.match(/^http(s?):/) !== null;

module.exports = (uri, options, callback) => {
const opt = options || {};
const cb = callback || (() => {});
let runner = path.join(phantomjsRunnerDir, 'runner-json.js');
const testUri = isUrl(uri) ? uri : `file:///${path.resolve(uri).replace(/\\/g, '/')}`;
let childArgs = [];
let proc;

if (opt.verbose) {
runner = path.join(phantomjsRunnerDir, 'runner-list.js');
Expand Down Expand Up @@ -52,16 +48,16 @@ module.exports = function (uri, options, callback) {
childArgs.push(JSON.stringify(opt.page));
}

console.log('Testing ' + chalk.blue(testUri));
console.log(`Testing ${chalk.blue(testUri)}`);

// phantomjs [phantomjs-options] runner testuri [timeout [page]]
proc = childProcess.spawn(binPath, childArgs);

proc.stdout.on('data', function (data) {
var out,
test,
message,
line = data.toString().trim();
proc.stdout.on('data', data => {
let out;
let test;
let message;
const line = data.toString().trim();

try {
out = JSON.parse(line);
Expand All @@ -72,22 +68,20 @@ module.exports = function (uri, options, callback) {

if (out.exceptions) {
for (test in out.exceptions) {
console.log('\n' + chalk.red('Test failed') + ': ' + chalk.red(test) + ': \n' + out.exceptions[test].join('\n '));
console.log(`\n${chalk.red('Test failed')}: ${chalk.red(test)}: \n${out.exceptions[test].join('\n ')}`);
}
}

if (out.result) {
message = 'Took ' + out.result.runtime + ' ms to run ' + out.result.total + ' tests. ' + out.result.passed + ' passed, ' + out.result.failed + ' failed.';
message = `Took ${out.result.runtime} ms to run ${out.result.total} tests. ${out.result.passed} passed, ${out.result.failed} failed.`;

console.log(out.result.failed > 0 ? chalk.red(message) : chalk.green(message));
}
});

proc.stderr.on('data', function (data) {
proc.stderr.on('data', data => {
console.log(data.toString().trim());
});

proc.on('close', function (code) {
return cb(code);
});
proc.on('close', code => cb(code));
};
Loading

0 comments on commit 1086895

Please sign in to comment.