Browse files

Making it a little more programatic

  • Loading branch information...
1 parent 64c36d5 commit 4e8ff26b266c5c96fc771f0602c89bf9104f407d @davglass committed Jul 24, 2012
Showing with 9 additions and 7 deletions.
  1. +2 −0 bin/cli.js
  2. +7 −7 lib/index.js
View
2 bin/cli.js
@@ -1,12 +1,14 @@
#!/usr/bin/env node
var cli = require('cli'),
+ path = require('path'),
local = require('yui-local');
cli.enable('help');
cli.parse({
version: ['v', 'Show app version'],
+ build: ['b', 'Path to yui build dir', 'path', path.join(process.cwd(), 'build')],
port: ['p', 'The port number to assign: default 3000', 'number', 3000]
});
View
14 lib/index.js
@@ -6,14 +6,14 @@ var combo = require('combohandler'),
stamp = 'yui3-local',
path = require('path'),
fs = require('fs'),
- exists = fs.existsSync || path.existsSync,
- p = path.join(process.cwd(), 'build');
-
-if (!exists(p)) {
- throw("Can't find " + p + " directory, are you in the root of the YUI git repo?");
-}
+ exists = fs.existsSync || path.existsSync;
var start = function(opts) {
+ var p = opts.build;
+
+ if (!exists(p)) {
+ throw("Can't find " + p + " directory, are you in the root of the YUI git repo?");
+ }
app.get('/yui', combo.combine({rootPath: p }), function (req, res) {
res.body = seed.filter(res.body, stamp);
@@ -26,7 +26,7 @@ var start = function(opts) {
});
app.get('/build/'+'*', function(req, res) {
- var file = path.join(process.cwd(), 'build', req.params[0]);
+ var file = path.join(p, req.params[0]);
fs.readFile(file, function(err, data) {
res.contentType(file);
if (path.extname(file) === '.js') {

0 comments on commit 4e8ff26

Please sign in to comment.