Skip to content

Commit

Permalink
Add sample server for #4
Browse files Browse the repository at this point in the history
  • Loading branch information
hotoo committed Oct 3, 2014
1 parent 595c6aa commit 776a5ac
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
_site/
spm_modules/
.DS_Store
node_modules/
35 changes: 35 additions & 0 deletions bin/markline
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env node

var commander = require('commander');
var markline = require("../index");

commander
.version(require('../package').version)
.usage('[options]')
.option('-v, --version', 'output the version number')
.option('build', 'build markdown to markline page.')
.option('server', 'build markdown to markline page.')
.parse(process.argv);


var cwd = process.cwd();
var options = {
src: commander.source || cwd,
dist: commander.dist || cwd + "/dist"
};

if (commander.build) {
markline.build(options);
process.exit();
} else if (commander.server){
markline.server(options);
process.exit();
}

// output help and exit if no args found
if (commander.args.length === 0) {
commander.help();
}


// vim:ft=javascript
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

function build(options){
console.log(options.src)
console.log(options.dist)
}

function server(options){
var http = require('http');
var app = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
});
app.listen(8080);
console.log("Server Started 127.0.0.1:8080")
}

function watch(){
}

module.exports = {
build: build,
server: server,
watch: watch
}
14 changes: 12 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@
"bugs": {
"url": "https://github.com/hotoo/markline/issues"
},
"licenses": "MIT",
"bin": {
"pinyin": "./bin/pinyin"
},
"dependencies": {
"commander": "~1.1.1"
},
"devDependencies": {
"mocha": "1.17.1",
"expect.js": "0.3.1"
},
"spm": {
"main": "markline.js",
"output": ["timeline.js", "timeline.css"],
Expand All @@ -22,5 +31,6 @@
"devDependencies": {
"expect.js": "0.3.1"
}
}
},
"licenses": "MIT"
}

0 comments on commit 776a5ac

Please sign in to comment.