Skip to content

Commit

Permalink
connect with Travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
miniflycn committed Feb 2, 2014
1 parent d337c79 commit 7ead791
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
@@ -0,0 +1,5 @@
language: node_js
node_js:
- "0.10"
before_script:
- npm install -g grunt-cli
16 changes: 12 additions & 4 deletions Gruntfile.js
@@ -1,5 +1,5 @@
module.exports = function( grunt ) {
"use strict";
'use strict';

grunt.initConfig({
uglify: {
Expand All @@ -11,7 +11,7 @@ module.exports = function( grunt ) {
preserveComments: false,
sourceMap: "dist/dwarf.min.map",
sourceMappingURL: "dwarf.min.map",
report: "min",
report: "gzip",
beautify: {
ascii_only: true
},
Expand All @@ -24,6 +24,13 @@ module.exports = function( grunt ) {
}
}
},
copy: {
test: {
files: [
{expand: true, cwd: 'src/', src: ['*'], dest: 'test/js/'}
]
}
},
mocha_phantomjs: {
options: {
'reporter': 'xunit',
Expand All @@ -33,8 +40,9 @@ module.exports = function( grunt ) {
}
});

// Load grunt tasks from NPM packages
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-mocha-phantomjs');

grunt.registerTask("default", [ "uglify" ]);
grunt.registerTask('default', ['uglify', 'copy', 'mocha_phantomjs']);
};
5 changes: 4 additions & 1 deletion Readme.md
Expand Up @@ -15,7 +15,10 @@ Why?

Goal
----
旨在配合线下构建工具,带来更好的编程体验,例如源代码是这样写的:

* 足够小,gzip之后小于1k
* 旨在配合线下构建工具,带来更好的编程体验,例如源代码是这样写的:

src/main.js
```
require(function () {
Expand Down
2 changes: 1 addition & 1 deletion dist/dwarf.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/dwarf.min.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Expand Up @@ -10,6 +10,10 @@
"devDependencies": {
"grunt": "*",
"grunt-contrib-uglify": "*",
"grunt-mocha-phantomjs": "~0.4.0"
"grunt-mocha-phantomjs": "~0.4.0",
"grunt-contrib-copy": "~0.5.0"
},
"scripts": {
"test": "grunt"
}
}
25 changes: 17 additions & 8 deletions src/dwarf.js
Expand Up @@ -121,7 +121,7 @@
loader = new Loader(module, true);
Cache.set(module, loader);
}
return loader.setFactory(factory);
return loader.set(factory);
});
});
stack.length = 0;
Expand Down Expand Up @@ -174,19 +174,29 @@
node.removeEventListener('error', _onerror, false);
}
},
/**
* _push
* @private
* @param {Array} list
* @param {Function} cb
*/
_push: function (list, cb) {
if (!list.some(function (item) { return item === cb }))
return list.push(cb);
},
/**
* succ
* @param {Function} cb
*/
succ: function (cb) {
return this.succList.push(cb);
return this._push(this.succList, cb);
},
/**
* fail
* @param {Function} cb
*/
fail: function (cb) {
return this.failList.push(cb);
return this._push(this.failList, cb);
},
/**
* done
Expand Down Expand Up @@ -223,10 +233,10 @@
}
},
/**
* setFactory
* set
* @param {Function} factory
*/
setFactory: function (factory) {
set: function (factory) {
this.factory = factory;
return this.done();
}
Expand All @@ -243,18 +253,17 @@
var base = opts.base;
function _r(deps, succ, fail) {
if (succ) {
// TODO: This checker have some mistakes
function _checkDeps() {
deps.slice(0).forEach(function (dep, i) {
dep = _normalize(base, dep);
var loader = Cache.get(dep);
if (!loader) {
loader = new Loader(dep);
Cache.set(dep, loader);
loader.succ(_checkDeps);
return loader.fail(fail);
}
if (loader.loaded) return deps.splice(i, 1);
loader.succ(_checkDeps);
return loader.fail(fail);
});
if (!deps.length) return succ();
}
Expand Down
25 changes: 17 additions & 8 deletions test/js/dwarf.js
Expand Up @@ -121,7 +121,7 @@
loader = new Loader(module, true);
Cache.set(module, loader);
}
return loader.setFactory(factory);
return loader.set(factory);
});
});
stack.length = 0;
Expand Down Expand Up @@ -174,19 +174,29 @@
node.removeEventListener('error', _onerror, false);
}
},
/**
* _push
* @private
* @param {Array} list
* @param {Function} cb
*/
_push: function (list, cb) {
if (!list.some(function (item) { return item === cb }))
return list.push(cb);
},
/**
* succ
* @param {Function} cb
*/
succ: function (cb) {
return this.succList.push(cb);
return this._push(this.succList, cb);
},
/**
* fail
* @param {Function} cb
*/
fail: function (cb) {
return this.failList.push(cb);
return this._push(this.failList, cb);
},
/**
* done
Expand Down Expand Up @@ -223,10 +233,10 @@
}
},
/**
* setFactory
* set
* @param {Function} factory
*/
setFactory: function (factory) {
set: function (factory) {
this.factory = factory;
return this.done();
}
Expand All @@ -243,18 +253,17 @@
var base = opts.base;
function _r(deps, succ, fail) {
if (succ) {
// TODO: This checker have some mistakes
function _checkDeps() {
deps.slice(0).forEach(function (dep, i) {
dep = _normalize(base, dep);
var loader = Cache.get(dep);
if (!loader) {
loader = new Loader(dep);
Cache.set(dep, loader);
loader.succ(_checkDeps);
return loader.fail(fail);
}
if (loader.loaded) return deps.splice(i, 1);
loader.succ(_checkDeps);
return loader.fail(fail);
});
if (!deps.length) return succ();
}
Expand Down

0 comments on commit 7ead791

Please sign in to comment.