Skip to content

Commit

Permalink
Simplify/modernize test run and code coverage calculations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ElliotNB committed Apr 1, 2022
1 parent 87a7623 commit ccaeee4
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 2,068 deletions.
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ node_js:
before_script:
- npm install
script:
- gulp test
- gulp lint
- gulp coveralls
- npm run test
- npm run lint
after_success:
- npm run coverage
cache:
directories:
- "node_modules"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,4 @@ Array mutations **can** be observed through the use of the array mutation method

## Contributing

Contributions are most welcome! Please be sure to run `gulp test` and `gulp lint` against your code before submitting a pull request.
Contributions are most welcome! Please be sure to run `npm run test` and `npm run lint` against your code before submitting a pull request.
39 changes: 1 addition & 38 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,10 @@
const process = require('process');
const path = require('path');
const gulp = require('gulp');
const uglify = require('gulp-uglify-es').default;
const useref = require('gulp-useref');
const rename = require('gulp-rename');
const mocha = require('gulp-mocha');
const babel = require('gulp-babel');
const eslint = require('gulp-eslint');
const shell = require('gulp-shell');

const observableSlimPath = './observable-slim.js';
const proxyPath = './proxy.js';
const testPath = './test/test.js';
const coverallsCoverageDirPath = './coverage';
const coverallsCoverageLcovPath = `${coverallsCoverageDirPath}/lcov.info`;
const coverallsBinPath = './node_modules/coveralls/bin/coveralls.js';
const coverallsCommand = (process.platform === 'win32')
// Windows (we have to resolve the paths).
? `nyc report --reporter=lcov`
+ ` && type ${path.resolve(coverallsCoverageLcovPath)} | ${path.resolve(coverallsBinPath)}`
+ ` && rmdir /s /q ${path.resolve(coverallsCoverageDirPath)}`
// Linux.
: `nyc report --reporter=lcov`
+ ` && cat ${coverallsCoverageLcovPath} | ${coverallsBinPath}`
+ ` && rm -rf ${coverallsCoverageDirPath}`;

gulp.task('default', (done) => gulp.src([observableSlimPath, proxyPath])
gulp.task('default', (done) => gulp.src(['./observable-slim.js', './proxy.js'])
.pipe(babel({
presets: ['@babel/preset-env'],
sourceType: 'script' // Prevent insertion of "use strict".
Expand All @@ -38,19 +17,3 @@ gulp.task('default', (done) => gulp.src([observableSlimPath, proxyPath])
.pipe(gulp.dest('./')) // Write it to the current directory.
.on('end', done)
);

gulp.task('test', (done) => gulp.src([testPath])
.pipe(mocha({
compilers: babel
}))
.on('end', done)
);

gulp.task('coveralls', shell.task([coverallsCommand]));

gulp.task('lint', (done) => gulp.src([observableSlimPath, proxyPath, testPath])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError()) // Brick on failure to be super strict.
.on('end', done)
);
Loading

0 comments on commit ccaeee4

Please sign in to comment.