IO.readFile(datadir + 'banditos.txt', function(err, sourceText) { assert.ok(!err); IO.readFile(destFile, function(err, destText){ assert.ok(!err); assert.equal(sourceText, destText); fs.unlink(destFile, callback); }); });
IO.readFile(sourceFile, function(err, sourceText) { assert.ok(!err); IO.readFile(destFile, function(err, destText){ assert.ok(!err); assert.equal(sourceText, destText); callback(); }); });
var cacheFile = function(path, callback) { IO.readFile(uiDirectory + path, function(err, data) { if (err) { return callback(err); } // Cache the file content staticFileCache[path] = data; callback(null, data); }); };
IO.copyFile(sourceFile, destFile, function(err) { assert.ok(!err); // Verify that the source and dest files contain the same data IO.readFile(sourceFile, function(err, sourceText) { assert.ok(!err); IO.readFile(destFile, function(err, destText){ assert.ok(!err); assert.equal(sourceText, destText); callback(); }); }); });
PreviewUtil.downloadRemoteFile('http://localhost:2000/api/me', tmpPath.path, function(err, path) { assert.ok(!err); IO.readFile(path, function(err, data) { assert.ok(!err); // Verify there is some data there. assert.ok(data); // Verify we don't leak the global session into the download fetcher. data = JSON.parse(data); assert.ok(data.anon); }); });
module.exports.loadFileIntoArray = function(filename, callback) { IO.readFile(filename, function(err, content) { var finallines = []; var lines = content.split("\n"); for (var i = 0; i < lines.length; i++) { lines[i] = lines[i].replace(/\r/g, ""); if (lines[i]){ finallines.push(lines[i]); } } callback(finallines); }); };
IO.moveFile(sourceFile, destFile, function(err) { assert.ok(!err); // Verify that the source file is removed fs.stat(sourceFile, function(err){ assert.equal(err.code, 'ENOENT'); }); // Verify that the source and dest files contain the same data IO.readFile(datadir + 'banditos.txt', function(err, sourceText) { assert.ok(!err); IO.readFile(destFile, function(err, destText){ assert.ok(!err); assert.equal(sourceText, destText); fs.unlink(destFile, callback); }); }); });
(function(fileName) { // Read each of the files in the provided directory IO.readFile(dir + '/' + fileName, function(err, data) { done++; if (!err) { // Parse the JSDocs using Dox try { doc[fileName] = dox.parseComments(data); } catch (ex) { log().warn({ err: ex, data: data }, 'Failed parsing comment data with dox for file %s. Ignoring.', dir + '/' + fileName); } } else { log().error({'err': err}, 'Failed reading ' + dir + '/' + fileName); } if (done === fileNames.length) { return callback(err, doc); } }); })(fileName);
fs.exists(templatePath, function(exists) { if (!exists) { return callback(); } IO.readFile(templatePath, function(err, templateContent) { if (err) { return callback(err); } if (templateContent) { var compiledTemplate = null; try { compiledTemplate = _.template(templateContent); } catch (ex) { return callback({'code': 500, 'msg': ex.message}); } return callback(null, compiledTemplate); } else { return callback({'code': 500, 'msg': 'Template file ' + templatePath + ' had no content.'}); } }); });