Version 1
[yaffs-website] / node_modules / temp / examples / grepcount.js
1 var temp = require('../lib/temp'),
2     fs   = require('fs'),
3     util = require('util'),
4     exec = require('child_process').exec;
5
6 var myData = "foo\nbar\nfoo\nbaz";
7
8 temp.open('myprefix', function(err, info) {
9   if (err) throw err;
10   fs.write(info.fd, myData);
11   fs.close(info.fd, function(err) {
12     if (err) throw err;
13     exec("grep foo '" + info.path + "' | wc -l", function(err, stdout) {
14       if (err) throw err;
15       util.puts(stdout.trim());
16     });
17   });
18 });