Skip to content

Commit

Permalink
adding unix pipe capability.
Browse files Browse the repository at this point in the history
Ex 
$ cat example-osm/way.osm | ./mongosm -update
  • Loading branch information
sammerry committed Jul 21, 2013
1 parent b23c7c1 commit ae0bf7b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions lib/mongosm.js
Expand Up @@ -95,8 +95,15 @@ mongoose.connection.on('open', function () {

saxStream.on("opentag", parse);
saxStream.on("closetag", closetag);
fs.createReadStream(options.filename)
.pipe(saxStream);

if (options.filename) {
fs.createReadStream(options.filename)
.pipe(saxStream);
} else {
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.pipe(saxStream);
}

saxStream.on("end", function() {
eof = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/options.js
Expand Up @@ -3,7 +3,7 @@ module.exports = {
uri: ""
},
verbose: false,
filename: "example-osm/way.osm",
//filename: "example-osm/way.osm",
host: "localhost",
port: "27017",
database: "test",
Expand Down

0 comments on commit ae0bf7b

Please sign in to comment.