Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
use babel, add eslint, fix eslint errors, adding build step
Browse files Browse the repository at this point in the history
Signed-off-by: Charles Hansen <chansen@pivotal.io>
  • Loading branch information
rdy authored and charleshansen committed May 8, 2015
1 parent e11992b commit b2103ab
Show file tree
Hide file tree
Showing 19 changed files with 156 additions and 49 deletions.
56 changes: 56 additions & 0 deletions .eslintrc
@@ -0,0 +1,56 @@
{
"env": {
"node": true,
"jasmine": true
},

"ecmaFeatures": {
"arrowFunctions": true,
"blockBindings": true,
"binaryLiterals": true,
"classes": true,
"defaultParams": true,
"destructuring": true,
"forOf": true,
"generators": true,
"jsx": true,
"objectLiteralComputedProperties": true,
"objectLiteralDuplicateProperties": true,
"objectLiteralShorthandMethods": true,
"objectLiteralShorthandProperties": true,
"octalLiterals": true,
"regexYFlag": true,
"regexUFlag": true,
"restParams": true,
"spread": true,
"superInFunctions": true,
"templateStrings": true,
"unicodeCodePointEscapes": true
},

"plugins": [
"react"
],

"rules": {
"camelcase": 0,
"curly": 0,
"eol-last": 0,
"no-undef": 0,
"no-path-concat": 0,
"no-process-exit": 0,
"no-shadow": 0,
"no-underscore-dangle": 0,
"no-unused-expressions": 0,
"quotes": [1, "single"],
"react/jsx-uses-vars": 1,
"react/jsx-no-undef": 1,
"react/jsx-quotes": [1, "double", "avoid-escape"],
"react/no-did-mount-set-state": 1,
"react/no-did-update-set-state": 1,
"react/prop-types": [1, {ignore: ['children', 'className', 'id', 'style']}],
"react/self-closing-comp": 1,
"react/wrap-multilines": 1,
"strict": 0
}
}
4 changes: 3 additions & 1 deletion .gitignore
@@ -1 +1,3 @@
/node_modules
node_modules/*
dist/*
.idea/*
4 changes: 4 additions & 0 deletions gulpfile.js
@@ -0,0 +1,4 @@
require('babel/register');
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var requireDir = require('require-dir');
requireDir('./tasks');
30 changes: 22 additions & 8 deletions package.json
Expand Up @@ -3,25 +3,39 @@
"version": "0.0.4",
"license": "MIT",
"description": "",
"keywords": [],
"keywords": [
"gulp",
"gulpplugin",
"jasmine",
"test",
"testing",
"spec"
],
"homepage": "https://github.com/jasmine/gulp-jasmine-browser",
"bugs": "https://github.com/jasmine/gulp-jasmine-browser/issues",
"files": [
"index.js",
"README.md",
"LICENSE.md",
"lib"
],
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/jasmine/gulp-jasmine-browser"
},
"devDependencies": {
"babel": "^5.2.17",
"cheerio": "^0.18.0",
"del": "^1.1.1",
"eslint": "^0.20.0",
"eslint-plugin-react": "^2.2.0",
"gulp": "^3.8.11",
"gulp-babel": "^5.1.0",
"gulp-eslint": "^0.11.1",
"gulp-jasmine": "^2.0.1",
"gulp-load-plugins": "^0.10.0",
"gulp-plumber": "^1.0.0",
"gulp-webpack": "^1.3.0",
"jasmine": "^2.2.0",
"merge-stream": "^0.1.7",
"npm": "^2.9.1",
"require-dir": "^0.3.0",
"run-sequence": "^1.1.0",
"selenium-standalone": "^4.2.0",
"webdriverio": "^2.4.5"
},
Expand All @@ -37,6 +51,6 @@
"gulp": "^3.8.11"
},
"scripts": {
"test": "node_modules/.bin/jasmine"
"test": "gulp"
}
}
2 changes: 1 addition & 1 deletion spec/fixtures/gulpfile.js
@@ -1,6 +1,6 @@
var gulp = require('gulp');
var webpack = require('gulp-webpack');
var jasmineBrowser = require('../../index');
var jasmineBrowser = require('../../src/index');

gulp.task('phantomjs', function() {
return gulp.src('dummy_spec.js')
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/mutable_spec.js
@@ -1 +1 @@
it('makes a basic failing assertion',function() { expect(true).toBe(false); });
it('makes a basic failing assertion', function() { expect(true).toBe(false); });
30 changes: 12 additions & 18 deletions spec/index_spec.js
Expand Up @@ -6,12 +6,12 @@ var webdriverio = require('webdriverio');

jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;

function gulp(task, callback) {
function gulp(task, callback) {
var gulpPath = path.resolve('node_modules', '.bin', 'gulp');
var gulpFile = path.resolve(__dirname, 'fixtures', 'gulpfile.js');
return childProcess.exec([gulpPath, '--gulpfile', gulpFile, task].join(' '),
{timeout: 5000}, callback);
return childProcess.exec([gulpPath, '--gulpfile', gulpFile, task].join(' '),
{timeout: 5000}, callback);

}

function withSelenium(callback) {
Expand Down Expand Up @@ -68,7 +68,7 @@ describe('gulp-jasmine-browser', function() {
return webdriver
.url('http://localhost:8888')
.getText('.bar.failed', function(error, text) {
expect(text).toBe('2 specs, 1 failure')
expect(text).toBe('2 specs, 1 failure');
})
.end(function() {
seleniumServer.kill();
Expand All @@ -85,7 +85,7 @@ describe('gulp-jasmine-browser', function() {
.url('http://localhost:8888')
.refresh()
.getText('.bar.failed', function(error, text) {
expect(text).toBe('2 specs, 1 failure')
expect(text).toBe('2 specs, 1 failure');
})
.end(function() {
seleniumServer.kill();
Expand All @@ -96,24 +96,18 @@ describe('gulp-jasmine-browser', function() {

it('supports webpack with watch: true', function(done) {
var mutableSpec = path.resolve(__dirname, 'fixtures', 'mutable_spec.js');
var oldSpec = "" +
"it('makes a basic failing assertion'," +
"function() { expect(true).toBe(false); " +
"});";
var newSpec = "" +
"it('makes a basic passing assertion'," +
"function() { expect(true).toBe(true); " +
"});";
var oldSpec = `it('makes a basic failing assertion', function() { expect(true).toBe(false); });`;
var newSpec = `it('makes a basic passing assertion', function() { expect(true).toBe(true); });`;
var gulpProcess = gulp('webpack-server');
gulpProcess.on('close', function() {
fs.writeSync(fs.openSync(mutableSpec, 'w'), oldSpec);
done();
});
withSelenium(function(seleniumServer, webdriver) {

webdriver.addCommand("waitForWebpack", function(cb) {
webdriver.addCommand('waitForWebpack', function(cb) {
gulpProcess.stdout.on('data', function(chunk) {
if (chunk.match(/Webpack is watching for changes/)) {
if (chunk.match(/webpack is watching for changes/i)) {
cb();
}
});
Expand All @@ -122,15 +116,15 @@ describe('gulp-jasmine-browser', function() {
webdriver
.url('http://localhost:8888')
.getText('.bar.failed', function(error, text) {
expect(text).toBe('1 spec, 1 failure')
expect(text).toBe('1 spec, 1 failure');
})
.call(function() {
fs.writeSync(fs.openSync(mutableSpec, 'w'), newSpec);
})
.waitForWebpack()
.refresh()
.getText('.bar.passed', function(error, text) {
expect(text).toBe('1 spec, 0 failures')
expect(text).toBe('1 spec, 0 failures');
})
.end(function() {
seleniumServer.kill();
Expand Down
9 changes: 3 additions & 6 deletions spec/spec_runner_spec.js
Expand Up @@ -2,19 +2,16 @@ var fs = require('fs');
var path = require('path');
var cheerio = require('cheerio');
var jasmineCore = require('jasmine-core');
var SpecRunner = require('../lib/spec_runner');
var SpecRunner = require('../src/lib/spec_runner');

var jasmineJsFiles = jasmineCore.files.jsFiles.map(function(fileName) {
return fs.readFileSync(path.resolve(jasmineCore.files.path, fileName), 'utf8');
});
var jasmineCssFiles = jasmineCore.files.cssFiles.map(function(fileName) {
return fs.readFileSync(path.resolve(jasmineCore.files.path, fileName), 'utf8');
});
var jasmineBootFiles = jasmineCore.files.bootFiles.map(function(fileName) {
return fs.readFileSync(path.resolve(jasmineCore.files.bootDir, fileName), 'utf8');
});
var consoleJs = fs.readFileSync(path.resolve(__dirname, '..', 'lib', 'console.js'), 'utf8');
var consoleBootJs = fs.readFileSync(path.resolve(__dirname, '..', 'lib', 'console_boot.js'), 'utf8');
var consoleJs = fs.readFileSync(path.resolve(__dirname, '..', 'src', 'lib', 'console.js'), 'utf8');
var consoleBootJs = fs.readFileSync(path.resolve(__dirname, '..', 'src', 'lib', 'console_boot.js'), 'utf8');

describe('SpecRunner', function() {
var specRunnerFile;
Expand Down
10 changes: 0 additions & 10 deletions spec/support/jasmine.json

This file was deleted.

4 changes: 2 additions & 2 deletions index.js → src/index.js
Expand Up @@ -17,7 +17,7 @@ function startNewServer(port, stream, files, callback) {
res.status(200).type(mime.lookup(pathname)).send(contents.toString());
return;
}
res.status(404).send('File not Found')
res.status(404).send('File not Found');
}
var app = express();
var server = app.listen(port, function() {
Expand Down Expand Up @@ -60,7 +60,7 @@ function createServer(options, callback) {
stream.next = function() {
stream.allowedToContinue = true;
done();
}
};
});
stream.next = function() {
stream.allowedToContinue = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/console.js → src/lib/console.js
Expand Up @@ -183,4 +183,4 @@ getJasmineRequireObj().ConsoleReporter = function() {
}

return ConsoleReporter;
};
};
2 changes: 1 addition & 1 deletion lib/console_boot.js → src/lib/console_boot.js
Expand Up @@ -15,7 +15,7 @@
var consoleReporter = new jasmine.ConsoleReporter({
showColors: true,
timer: new jasmine.Timer(),
print: function(message) { console.log(message) },
print: function(message) { console.log(message); },
onComplete: callPhantom
});

Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions tasks/build.js
@@ -0,0 +1,15 @@
var del = require('del');
var gulp = require('gulp');
var mergeStream = require('merge-stream');
var plugins = require('gulp-load-plugins')();

gulp.task('clean', function(callback) {
del('dist', callback);
});

gulp.task('build', ['clean'], function() {
return mergeStream(
gulp.src('src/**/*.js').pipe(plugins.babel()),
gulp.src(['LICENSE', 'README.md', 'package.json'])
).pipe(gulp.dest('dist'));
});
6 changes: 6 additions & 0 deletions tasks/default.js
@@ -0,0 +1,6 @@
var gulp = require('gulp');
var runSequence = require('run-sequence');

gulp.task('default', function(callback) {
runSequence('lint', 'spec', callback);
});
8 changes: 8 additions & 0 deletions tasks/jasmine.js
@@ -0,0 +1,8 @@
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();

gulp.task('spec', function() {
return gulp.src(['spec/**/*_spec.js', '!spec/fixtures/**/*.js'])
.pipe(plugins.plumber())
.pipe(plugins.jasmine());
});
10 changes: 10 additions & 0 deletions tasks/lint.js
@@ -0,0 +1,10 @@
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();

gulp.task('lint', function() {
return gulp.src(['gulpfile.js', 'tasks/**/*.js', 'src/**/*.js', 'spec/**/*.js', '!src/lib/console.js'])
.pipe(plugins.plumber())
.pipe(plugins.eslint())
.pipe(plugins.eslint.format('stylish'))
.pipe(plugins.eslint.failOnError());
});
11 changes: 11 additions & 0 deletions tasks/publish.js
@@ -0,0 +1,11 @@
var gulp = require('gulp');
var npm = require('npm');

gulp.task('publish', ['build'], function(){
npm.load({}, function(error) {
if (error) return console.error(error);
npm.commands.publish(['dist'], function(error) {
if (error) return console.error(error);
});
});
});

0 comments on commit b2103ab

Please sign in to comment.