Skip to content

Commit

Permalink
update tc
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed Oct 29, 2014
1 parent b640561 commit 25187e0
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 106 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mx_modules/
bower_components/
nohup.out
*.iml
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mx_modules/
bower_components/
tests/
node_modules/
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ before_script:
- node --harmony server &
- npm install gulp bower mocha-phantomjs -g
- bower install
- gulp mx
- phantomjs --version
script:
- npm test
Expand Down
2 changes: 2 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
],
"devDependencies": {
"modulex": "*",
"modulex-feature": "1.x",
"modulex-ua": "1.x",
"async": "~0.9.0"
}
}
5 changes: 5 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ gulp.task('build', ['lint'], function () {
.pipe(gulp.dest(path.resolve(build)));
});

gulp.task('mx', function () {
var aggregateBower = require('aggregate-bower');
aggregateBower('bower_components/', 'mx_modules/');
});

gulp.task('tag', function (done) {
var cp = require('child_process');
var version = packageInfo.version;
Expand Down
143 changes: 73 additions & 70 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,72 +1,75 @@
{
"name": "modulex-event-custom",
"version": "1.0.2",
"author": "yiminghe <[email protected]>",
"engines": {
"node": "~0.11"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "http://github.com/kissyteam/event-custom.git"
},
"testling": {
"server": "server.js",
"html": "tests/runner.html",
"browsers": [
"ie/6..latest",
"chrome/latest",
"firefox/latest",
"safari/latest",
"iphone/6..lastest",
"ipad/6..latest",
"android-browser/latest"
]
},
"devDependencies": {
"expect.js": "^0.3.1",
"gulp": "^3.8.7",
"gulp-clean": "^0.3.1",
"gulp-filter": "^1.0.0",
"gulp-footer": "^1.0.5",
"gulp-header": "^1.0.5",
"gulp-jscs": "^1.1.0",
"gulp-jshint": "^1.8.4",
"gulp-kclean": "0.0.15",
"gulp-modulex": "^1.0.0",
"gulp-rename": "^1.2.0",
"gulp-replace": "^0.4.0",
"gulp-uglify": "^0.3.1",
"gulp-util": "^3.0.0",
"jshint": "^2.5.5",
"jshint-stylish": "^0.4.0",
"kison": "^0.3.5",
"koa": "^0.11.0",
"koa-body": "^0.2.0",
"koa-mount": "^1.3.0",
"koa-serve-index": "^1.0.1",
"koa-static": "^1.4.7",
"mocha": "^1.21.4",
"node-jscover": "^0.6.8",
"node-jscover-coveralls": "^1.0.10",
"node-jscover-handler": "^1.0.3",
"gulp-wrapper": "^0.1.5",
"precommit-hook": "^1.0.7"
},
"precommit": [
"lint"
],
"scripts": {
"start": "node --harmony server",
"publish": "gulp tag",
"test": "node ./node_modules/mocha/bin/mocha -R list tests/node/specs",
"lint": "gulp lint",
"browser-test": "mocha-phantomjs http://localhost:8014/tests/browser/runner.html",
"browser-test-build": "mocha-phantomjs http://localhost:8014/tests/browser/runner.html?build",
"browser-test-cover": "mocha-phantomjs -R node_modules/node-jscover/lib/reporters/mocha/console http://localhost:8014/tests/browser/runner.html?coverage"
},
"dependencies": {
"modulex-event-base": "^1.0.1",
"modulex-util": "^1.1.0"
}
"name": "modulex-event-custom",
"version": "1.0.2",
"author": "yiminghe <[email protected]>",
"engines": {
"node": "~0.11"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "http://github.com/kissyteam/event-custom.git"
},
"testling": {
"server": "server.js",
"html": "tests/runner.html",
"browsers": [
"ie/6..latest",
"chrome/latest",
"firefox/latest",
"safari/latest",
"iphone/6..lastest",
"ipad/6..latest",
"android-browser/latest"
]
},
"devDependencies": {
"aggregate-bower": "^1.0.10",
"expect.js": "^0.3.1",
"gulp": "^3.8.7",
"gulp-clean": "^0.3.1",
"gulp-filter": "^1.0.0",
"gulp-footer": "^1.0.5",
"gulp-header": "^1.0.5",
"gulp-jscs": "^1.1.0",
"gulp-jshint": "^1.8.4",
"gulp-kclean": "0.0.15",
"gulp-modulex": "^1.0.0",
"gulp-rename": "^1.2.0",
"gulp-replace": "^0.4.0",
"gulp-uglify": "^0.3.1",
"gulp-util": "^3.0.0",
"gulp-wrapper": "^0.1.5",
"jshint": "^2.5.5",
"jshint-stylish": "^0.4.0",
"kison": "^0.3.5",
"koa": "^0.11.0",
"koa-body": "^0.2.0",
"koa-modularize": "^1.0.0",
"koa-mount": "^1.3.0",
"koa-node-jscover": "^1.0.0",
"koa-serve-index": "^1.0.1",
"koa-static": "^1.4.7",
"mocha": "^1.21.4",
"node-jscover": "^0.6.8",
"node-jscover-coveralls": "^1.0.10",
"node-jscover-handler": "^1.0.3",
"precommit-hook": "^1.0.7"
},
"precommit": [
"lint"
],
"scripts": {
"start": "node --harmony server",
"publish": "gulp tag",
"test": "node ./node_modules/mocha/bin/mocha -R list tests/node/specs",
"lint": "gulp lint",
"browser-test": "mocha-phantomjs http://localhost:8014/tests/browser/runner.html",
"browser-test-build": "mocha-phantomjs http://localhost:8014/tests/browser/runner.html?build",
"browser-test-cover": "mocha-phantomjs -R node_modules/node-jscover/lib/reporters/mocha/console http://localhost:8014/tests/browser/runner.html?coverage"
},
"dependencies": {
"modulex-event-base": "^1.0.1",
"modulex-util": "^1.1.0"
}
}
41 changes: 10 additions & 31 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,25 @@ var gutil = require('gulp-util');
var koa = require('koa');
var koaBody = require('koa-body');
var path = require('path');
var jscoverHandler = require('node-jscover-handler/lib/koa');
var jscoverHandler = require('koa-node-jscover');
var jscoverCoveralls = require('node-jscover-coveralls/lib/koa');
var serve = require('koa-static');
var fs = require('fs');
var app = koa();
var mount = require('koa-mount');
var cwd = process.cwd();
var serveIndex = require('koa-serve-index');
var modularize = require('koa-modularize');

function *modularize(next) {
var req = this.request;
var res = this.response;
if (path.extname(this.path) !== '.js') {
yield *next;
return;
}
var filePath = path.resolve(cwd, req.originalUrl.substring(1)).replace(/-coverage\.js/, '.js');
var stats = fs.statSync(filePath);
if (!stats.isFile()) {
yield *next;
return;
}
var code = fs.readFileSync(filePath, 'utf-8');
code = 'modulex.add(function(require,exports,module){' + code + '});';
if (req.path.indexOf('-coverage.js') !== -1) {
req.nodeJsCoverCode = code;
yield *next;
return;
}
res.set('content-type', 'application/javascript;charset=utf-8');
this.body = code;
}

// parse application/x-www-form-urlencoded
app.use(koaBody());
app.use(mount('/lib/', modularize));
app.use(mount('/tests/browser/specs/', modularize));

app.use(jscoverHandler({
jscover:require('node-jscover'),
next:function(){
return 1;
}
}));
app.use(mount('/lib/', modularize(path.resolve(__dirname,'lib'))));
app.use(mount('/tests/browser/specs/',modularize(path.resolve(__dirname,'tests/browser/specs/'))));
app.use(jscoverCoveralls());
app.use(jscoverHandler());
app.use(serveIndex(cwd, {
hidden: true,
view: 'details'
Expand Down
10 changes: 5 additions & 5 deletions tests/browser/runner.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
<h1 style="text-align: center">event-custom tests</h1>

<div id='mocha'></div>
<script src="/bower_components/modulex/build/modulex-debug.js"></script>
<script src="/bower_components/event-base/build/event-base-debug.js"></script>
<script src="/bower_components/event-base/meta/alias.js"></script>
<script src="/bower_components/util/build/util-debug.js"></script>
<script src="/bower_components/util/meta/alias.js"></script>
<script src="/mx_modules/modulex-debug.js"></script>
<script src="/mx_modules/ua-debug.js"></script>
<script src="/mx_modules/feature-debug.js"></script>
<script src="/mx_modules/meta.js"></script>
<script src="/meta/alias.js"></script>

<script src="/bower_components/async/lib/async.js"></script>
Expand Down Expand Up @@ -58,6 +57,7 @@ <h1 style="text-align: center">event-custom tests</h1>
<script>
(function () {
modulex.config({
base:'/mx_modules',
packages: {
specs: {
base: '/tests/browser/specs'
Expand Down

0 comments on commit 25187e0

Please sign in to comment.