Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Some refactoring

  • Loading branch information...
commit efe0c3138f84296009ec643f35f60207fcf5e25a 1 parent 1994101
Mario Behrendt authored
View
2  Chukfile
@@ -1,3 +1,5 @@
+// vim:set ft=javascript:
+
module.exports = function(scope) {
scope.cb = require('./lib/cb')(scope);
};
View
1  bin/chuk
@@ -1,5 +1,4 @@
#!/usr/bin/env node
var env = process.argv[2] || 'default';
-
require('../lib/index.js')(env);
View
2  example/Chukfile
@@ -1,3 +1,5 @@
+// vim:set ft=javascript:
+
module.exports = {
'foo': function(scope) {
scope.foo = 1;
View
17 lib/index.js
@@ -1,6 +1,5 @@
-var repl = require('repl');
-
-var cwd = process.cwd();
+var repl = require('repl')
+ , cwd = process.cwd();
function isFunction(thing) {
return 'function' === typeof thing;
@@ -8,9 +7,9 @@ function isFunction(thing) {
function createRepl() {
return repl.start({
- prompt: "chuk > ",
- input: process.stdin,
- output: process.stdout
+ prompt: 'chuk > ',
+ input: process.stdin,
+ output: process.stdout
}).on('exit', function() {
console.log('Exit');
});
@@ -18,10 +17,10 @@ function createRepl() {
function getInitFromConfig(env, config) {
if (isFunction(config[env])) {
- // config is an object with property [env] which is a function
+ // config is an object with property [env] which is a function
return config[env];
} else if (isFunction(config['default']) && !env) {
- // config is an object with property 'default' which is a function
+ // config is an object with property 'default' which is a function
return config['default'];
} else if (isFunction(config)) {
// config is a function itself
@@ -33,7 +32,7 @@ function chuk(env, config) {
var chukRepl = createRepl();
var config = config || require(cwd + '/Chukfile');
var init = getInitFromConfig(env, config);
- init(chukRepl.context.global);
+ init(chukRepl.context);
return chukRepl;
};
View
11 package.json
@@ -7,19 +7,16 @@
"test": "make test"
},
"repository": "git://github.com/stephanhoyer/chuk.git",
- "author": [
- "Mario Behrendt <info@mario-behrendt.de>",
- "Stephan Hoyer <ste.hoyer@gmail.com>"
- ],
+ "author": "Stephan Hoyer <ste.hoyer@gmail.com>",
+ "contributors": ["Mario Behrendt <info@mario-behrendt.de>"],
"license": "MIT",
- "dependencies": {
- },
+ "dependencies": { },
"bin": {
"chuk": "./bin/chuk"
},
"devDependencies": {
"mocha": "1.7.3",
- "gently": "*",
+ "gently": "0.9.2",
"should": "1.2.1"
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.