1.0.11 • Published 8 years ago
utilityFileSystem v1.0.11
File utility for node programs
Utility functions for file system, debugging, logging your Node.js application.
Installation
First ensure that you have Node.js installed and then run the following:
npm install utilityFileSystemNote: I would love to hear from the people downloading this package about their reasons and what improvements they would like to see. Feel free to contact me at chuankengchou@gmail.com
Usage
Require the module for an instance of utilityFileSystem
Example 1: Write some content to a file
var utility = require('./utilityFileSystem');
//create few files...
utility.export('./sample.txt','content...');Output:
Created file: ./sample.txtExample 2: Read the contents of a file
var utility = require('./utilityFileSystem');
utility.readFile("./sample.txt");Output:
Reading file contents from ./sample.txtExample 3: Read the contents of a folder
var utility = require('./utilityFileSystem');
utility.readFolder("./package.json");
utility.readFolder("./sample");Output:
./package.json Target exists, but it is not a folder...use utility.readFile() instead.
./sample Folder exists and its contents are: test.txt,test1.txt,test2.txt,test3.txt,test4.txtExample 4: Log files
var obj = {jimmy: "chou"};
utility.logger(obj);Output:
{"jimmy":"chou"}
Created file: ./logs/2017-11-06T02:00:29.297Z.txtTests
To run the test suite, first install any dependencies and then run npm test:
npm install
npm testThings to note
The logging capability is aware of the process running. For example, if there is an existing logging file, any new instance of fileUtility will append to the existing.