Skip to content

Commit

Permalink
upgrade deps and fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
soda-x committed Jul 11, 2016
1 parent ba3ac13 commit bb01307
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 69 deletions.
5 changes: 5 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"parser": "babel-eslint",
"extends": "eslint-config-airbnb/base",
"rules": {
"no-console": [0]
},
"ecmaFeatures": {
"generators": 1,
"experimentalObjectRestSpread": true
},
"env": {
"node": true,
"mocha": true
}
}
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

# ref: https://github.com/npm/npm/issues/3059
publish:
npm run build
npm run compile
npm publish

publish-sync: publish
cnpm sync
tnpm sync
25 changes: 0 additions & 25 deletions appveyor.yml

This file was deleted.

33 changes: 16 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,32 @@
"main": "./lib",
"scripts": {
"build": "rm -rf lib && babel src --out-dir lib",
"test": "babel-node node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha --no-timeouts",
"lint": "eslint --ext .js src",
"test": "babel-node $(npm bin)/babel-istanbul cover $(npm bin)/_mocha -- --no-timeouts",
"lint": "eslint --ext .js src test",
"coveralls": "cat ./coverage/lcov.info | coveralls"
},
"pre-commit": [
"lint"
],
"dependencies": {
"coffee-script": "^1.10.0",
"internal-ip": "^1.2.0",
"weinre": "^2.0.0-pre-I0Z7U9OV"
},
"devDependencies": {
"babel-cli": "~6.2.0",
"babel-core": "~6.1.21",
"babel-istanbul": "^0.5.9",
"babel-plugin-add-module-exports": "~0.1.1",
"babel-preset-es2015": "~6.1.18",
"babel-preset-stage-0": "~6.1.18",
"atool-build": "0.7.x",
"babel-cli": "^6.10.1",
"babel-core": "^6.10.4",
"babel-eslint": "^6.1.0",
"babel-istanbul": "^0.11.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.5.0",
"coveralls": "^2.11.6",
"dora": "0.3.x",
"eslint": "~1.9.0",
"eslint-config-airbnb": "~1.0.0",
"internal-ip": "^1.1.0",
"mocha": "~2.3.4",
"pre-commit": "~1.1.2",
"supertest": "^1.1.0"
"dora-plugin-webpack": "0.6.x",
"eslint": "^2.9.0",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.10.2",
"mocha": "^2.5.3",
"supertest": "^1.2.0"
},
"babel": {
"presets": [
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default {
'middleware.before'() {
const { log, query } = this;
defaultOpts.boundHost = localIP;
defaultOpts = {...defaultOpts, ...query};
defaultOpts = { ...defaultOpts, ...query };

run(defaultOpts);
log.info(`weinre is started, servering at http://${defaultOpts.boundHost}:${defaultOpts.httpPort}`);
Expand All @@ -34,7 +34,7 @@ export default {
'middleware'() {
const { cwd } = this;

return function* (next) {
return function* middleFunc(next) {
const fileName = parse(this.url).pathname;
const filePath = join(cwd, fileName);
const isHTML = /\.html?$/.test(this.url.split('?')[0]);
Expand Down
57 changes: 35 additions & 22 deletions test/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,84 @@ import request from 'supertest';
const localIP = require('internal-ip')();
const port = '12345';

describe('index', function() {
this.timeout(50000);
describe('index', () => {
describe('livereload.js', () => {

const cwd = process.cwd();
before(done => {
process.chdir(join(__dirname, './fixtures/normal'));
process.chdir(join(__dirname, './fixtures/normal'));
dora({
port,
plugins: ['../../../src/index?{httpPort:8888}'],
cwd: join(__dirname, './fixtures/normal'),
});
setTimeout(done, 1000);
}, done);
});

after(() => {
process.chdir(cwd);
});

it('GET weinre /target/target-script-min.js#anonymous', done => {

request(`http://${localIP}:8888`)
.get('/target/target-script-min.js#anonymous')
.expect(200)
.end(function(err, res){
.end((err, res) => {
if (err) return done(err);
if (res.text.indexOf(`modjewel.require('weinre/target/Target').main()`) < 0) throw new Error("/target/target-script-min.js#anonymous is not correct");
done();
if (res.text.indexOf("modjewel.require('weinre/target/Target').main()") < 0) {
const e = new Error('/target/target-script-min.js#anonymous is not correct');

return done(e);
}

return done();
});
});

it('GET /index.html is injected the script /target/target-script-min.js#anonymous', done => {
request(`http://localhost:${port}`)
.get('/index.html')
.expect(200)
.end(function(err, res){
.end((err, res) => {
if (err) return done(err);
if (res.text.indexOf(`<script src='http://${localIP}:8888/target/target-script-min.js#anonymous'></script>`) < 0) throw new Error("/target/target-script-min.js#anonymous is not injected");
done();
if (res.text.indexOf(`<script src='http://${localIP}:8888/target/target-script-min.js#anonymous'></script>`) < 0) {
const e = new Error('/target/target-script-min.js#anonymous is not injected');

return done(e);
}

return done();
});
});

it('GET /lackdoctype.html is injected the script livereload.js', done => {
request(`http://localhost:${port}`)
.get('/lackdoctype.html')
.expect(200)
.end(function(err, res){
.end((err, res) => {
if (err) return done(err);
if (res.text.indexOf(`<script src='http://${localIP}:8888/target/target-script-min.js#anonymous'></script>`) < 0) throw new Error("/target/target-script-min.js#anonymous is not injected");
done();
if (res.text.indexOf(`<script src='http://${localIP}:8888/target/target-script-min.js#anonymous'></script>`) < 0) {
const e = new Error('/target/target-script-min.js#anonymous is not injected');

return done(e);
}

return done();
});
});

it('GET /index.js should not be handled', done => {
request(`http://localhost:${port}`)
.get('/index.js')
.expect(200)
.end(function(err, res){
.end((err, res) => {
if (err) return done(err);
if (res.text.indexOf('console.log(1);') < 0) throw new Error("other types of files should not be handled");
done();
if (res.text.indexOf('console.log(1);') < 0) {
const e = new Error('other types of files should not be handled');

return done(e);
}

return done();
});
});
});
});



0 comments on commit bb01307

Please sign in to comment.