diff --git a/index.js b/index.js index e0799a8..ca15358 100644 --- a/index.js +++ b/index.js @@ -1,10 +1,13 @@ /// -var through = require("through2"); var path = require("path"); -module.exports = function (jadeTemplate, mojo) { - if (mojo === void 0) { mojo = undefined; } - return through.obj(function (file, enc, cb) { - //run callback function to signal end of plugin process. - return cb(null, file); - }); +var pr = require("pushrocks"); +var fs = require("fs"); +var smartfile = { + //read File to string + readFileToString: function (filePath) { + var fileString; + fileString = fs.readFileSync(filePath, "utf8"); + return fileString; + } }; +module.exports = smartfile; diff --git a/package.json b/package.json index f91ee14..f2c1af3 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "offers smart ways to work with files in nodejs", "main": "index.js", "scripts": { - "test": "(cd ts/compile && node compile.js)", + "test": "(cd ts/compile && node compile.js) && (node test.js)", "reinstall": "(rm -r node_modules && npm install)", "release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)", "startdev": "(git checkout master && git pull origin master)" diff --git a/test.js b/test.js new file mode 100644 index 0000000..bfe9fa7 --- /dev/null +++ b/test.js @@ -0,0 +1,2 @@ +var smartfile = require("./index.js"); +console.log(smartfile.readFileToString("./test/mytest.txt")); diff --git a/test/mytest.txt b/test/mytest.txt new file mode 100644 index 0000000..2b48449 --- /dev/null +++ b/test/mytest.txt @@ -0,0 +1 @@ +This is some test text. If this is displayed when running "npm test", then the test has succeeded. \ No newline at end of file diff --git a/ts/compile/compile.js b/ts/compile/compile.js index b0d1228..a35699b 100644 --- a/ts/compile/compile.js +++ b/ts/compile/compile.js @@ -12,7 +12,16 @@ gulp.task('compileTS', function() { return stream; }); -gulp.task('default',['compileTS'], function() { +gulp.task('compileTestTS', function() { + var stream = gulp.src('../test.ts') + .pipe(gulpTypescript({ + out: "test.js" + })) + .pipe(gulp.dest("../../")); + return stream; +}); + +gulp.task('default',['compileTS','compileTestTS'], function() { pr.beautylog.success('Typescript compiled'); }); diff --git a/ts/index.ts b/ts/index.ts index 147677a..44778d4 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,12 +1,16 @@ /// -var through = require("through2"); var path = require("path"); +var pr = require("pushrocks"); +var fs = require("fs"); -module.exports = (jadeTemplate,mojo = undefined) => { - - return through.obj((file, enc, cb) => { - - //run callback function to signal end of plugin process. - return cb(null, file); - }); +var smartfile:any = { + //read File to string + readFileToString: (filePath) => { + var fileString; + fileString = fs.readFileSync(filePath, "utf8"); + return fileString; + } }; + + +module.exports = smartfile; diff --git a/ts/test.ts b/ts/test.ts new file mode 100644 index 0000000..3129849 --- /dev/null +++ b/ts/test.ts @@ -0,0 +1,2 @@ +var smartfile = require("./index.js"); +console.log(smartfile.readFileToString("./test/mytest.txt")); \ No newline at end of file