Skip to content

Commit

Permalink
cleaned up build (fix #417) + made coverage work again (fix #403) try…
Browse files Browse the repository at this point in the history
…ing to validate 1.10.3
  • Loading branch information
benmosher committed Jul 12, 2016
1 parent 2bb0163 commit f314e5c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 95 deletions.
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"presets": [ "es2015-loose" ],
"sourceMaps": "inline"
"sourceMaps": "inline",
"env": {
"test": {
"plugins": [ "istanbul" ]
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ node_modules

# generated output
lib/
/.nyc_output/
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@ test_script:
- cd .\resolvers\webpack && npm test && cd ..\..
- cd .\resolvers\node && npm test && cd ..\..

on_success:
- npm run coveralls

# Don't actually build.
build: off
90 changes: 3 additions & 87 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,102 +1,18 @@
var gulp = require('gulp')
, changed = require('gulp-changed')
, babel = require('gulp-babel')
, mocha = require('gulp-mocha')
, path = require('path')
, glob = require('glob')
, fs = require('fs')
, rimraf = require('rimraf')

var SRC = 'src/**/*.js'
, DEST = 'lib'

gulp.task('src', function () {
gulp.task('src', ['clean'], function () {
return gulp.src(SRC)
.pipe(changed(DEST))
.pipe(babel())
.pipe(gulp.dest(DEST))
})

/**
* Delete any file under `dest` that has no corresponding file in `src`.
* I.E. remove generated files that have been orphaned via deletion of their source.
* @param {string} src
* @param {string} dest
* @param {Function} done - callback upon completion
*/
function wipeExtras(src, dest, done) {
// glob into 'lib' and delete whatever isn't there
glob(dest + '/**/*.js', function (err, files) {
if (err) {
done(err); return
}

function checkFile(index) {
if (index >= files.length) {
done(); return
}

var libFilename = files[index]
, srcFilename = path.resolve(src, path.relative(path.resolve(dest), libFilename))

fs.stat(srcFilename, function (err) {
if (err) {
fs.unlink(libFilename, function () {
checkFile(index + 1)
})
} else {
checkFile(index + 1)
}
})
}


checkFile(0)
})
}

gulp.task('clean-src', function (done) {
gulp.task('clean', function (done) {
rimraf(DEST, done)
})

gulp.task('clean-tests', function (done) {
rimraf('tests/lib', done)
})

gulp.task('clean', ['clean-src', 'clean-tests'])

gulp.task('wipe-extras', function (done) {
var unfinished = 2
function megadone(err) {
if (err) { done(err); return }
if (--unfinished === 0) done()
}
wipeExtras('src', DEST, megadone)
wipeExtras('tests/src', 'tests/lib', megadone)
})

gulp.task('prepublish', ['src', 'wipe-extras'])

gulp.task('tests', function () {
return gulp.src('tests/src/**/*.js')
.pipe(changed('tests/lib'))
.pipe(babel())
.pipe(gulp.dest('tests/lib'))
})

// used externally by Istanbul, too
gulp.task('pretest', ['src', 'tests', 'wipe-extras'])

var reporter = 'spec'

gulp.task('test', ['pretest'], function () {
return gulp.src('tests/lib/**/*.js', { read: false })
.pipe(mocha({ reporter: reporter, grep: process.env.TEST_GREP, timeout: 5000 }))
// NODE_PATH=./lib mocha --recursive --reporter dot tests/lib/
})

gulp.task('watch-test', function () {
reporter = 'progress'
gulp.watch(SRC, ['test'])
gulp.watch('tests/' + SRC, ['test'])
})
gulp.task('prepublish', ['src'])
18 changes: 13 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
"watch": "cross-env NODE_PATH=./lib gulp watch-test",
"cover": "gulp pretest && cross-env NODE_PATH=./lib istanbul cover --dir reports/coverage _mocha tests/lib/ -- --recursive -R progress",
"posttest": "eslint ./src",
"test": "cross-env NODE_PATH=./lib gulp test",
"test": "cross-env BABEL_ENV=test NODE_PATH=./src nyc mocha --recursive tests/src -R progress -t 5s",
"coverage-report": "npm t && nyc report --reporter html",
"test-all": "npm test && for resolver in ./resolvers/*; do cd $resolver && npm test && cd ../..; done",
"ci-test": "eslint ./src && gulp pretest && cross-env NODE_PATH=./lib istanbul cover --report lcovonly --dir reports/coverage _mocha tests/lib/ -- --recursive --reporter dot",
"debug": "cross-env NODE_PATH=./lib mocha debug --recursive --reporter dot tests/lib/",
"prepublish": "gulp prepublish",
"coveralls": "cat ./reports/coverage/lcov.info | coveralls"
"coveralls": "nyc report --reporter lcovonly && cat ./coverage/lcov.info | coveralls"
},
"repository": {
"type": "git",
Expand All @@ -43,21 +44,21 @@
"homepage": "https://github.com/benmosher/eslint-plugin-import",
"devDependencies": {
"babel-eslint": "next",
"babel-plugin-istanbul": "^1.0.3",
"babel-preset-es2015": "^6.6.0",
"babel-preset-es2015-loose": "^7.0.0",
"babel-register": "6.9.0",
"chai": "^3.4.0",
"coveralls": "^2.11.4",
"cross-env": "^1.0.7",
"eslint": "2.x",
"eslint-import-resolver-node": "file:./resolvers/node",
"eslint-import-resolver-webpack": "file:./resolvers/webpack",
"glob": "^6.0.2",
"gulp": "^3.9.0",
"gulp-babel": "6.1.2",
"gulp-changed": "^1.3.0",
"gulp-mocha": "^2.2.0",
"istanbul": "^0.4.0",
"mocha": "^2.2.1",
"nyc": "^7.0.0",
"redux": "^3.0.4",
"rimraf": "2.5.2"
},
Expand All @@ -78,5 +79,12 @@
"object-assign": "^4.0.1",
"pkg-dir": "^1.0.0",
"pkg-up": "^1.0.0"
},
"nyc": {
"require": [
"babel-register"
],
"sourceMap": false,
"instrument": false
}
}
2 changes: 1 addition & 1 deletion tests/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('CLI regression tests', function () {
cli = new CLIEngine({
useEslintrc: false,
configFile: './tests/files/issue210.config.js',
rulePaths: ['./lib/rules'],
rulePaths: ['./src/rules'],
rules: {
'named': 2,
},
Expand Down
2 changes: 1 addition & 1 deletion tests/src/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var path = require('path')
, fs = require('fs')

describe('package', function () {
let pkg = path.join(process.cwd(), 'lib')
let pkg = path.join(process.cwd(), 'src')
, module

before('is importable', function () {
Expand Down

0 comments on commit f314e5c

Please sign in to comment.