This commit is contained in:
Philipp Kunz 2015-11-03 20:14:41 +01:00
parent 57c90ca504
commit 8d8d7e7ff4
7 changed files with 38 additions and 17 deletions

View File

@ -1,10 +1,13 @@
/// <reference path="typings/tsd.d.ts" /> /// <reference path="typings/tsd.d.ts" />
var through = require("through2");
var path = require("path"); var path = require("path");
module.exports = function (jadeTemplate, mojo) { var pr = require("pushrocks");
if (mojo === void 0) { mojo = undefined; } var fs = require("fs");
return through.obj(function (file, enc, cb) { var smartfile = {
//run callback function to signal end of plugin process. //read File to string
return cb(null, file); readFileToString: function (filePath) {
}); var fileString;
fileString = fs.readFileSync(filePath, "utf8");
return fileString;
}
}; };
module.exports = smartfile;

View File

@ -4,7 +4,7 @@
"description": "offers smart ways to work with files in nodejs", "description": "offers smart ways to work with files in nodejs",
"main": "index.js", "main": "index.js",
"scripts": { "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)", "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)", "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)" "startdev": "(git checkout master && git pull origin master)"

2
test.js Normal file
View File

@ -0,0 +1,2 @@
var smartfile = require("./index.js");
console.log(smartfile.readFileToString("./test/mytest.txt"));

1
test/mytest.txt Normal file
View File

@ -0,0 +1 @@
This is some test text. If this is displayed when running "npm test", then the test has succeeded.

View File

@ -12,7 +12,16 @@ gulp.task('compileTS', function() {
return stream; 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'); pr.beautylog.success('Typescript compiled');
}); });

View File

@ -1,12 +1,16 @@
/// <reference path="typings/tsd.d.ts" /> /// <reference path="typings/tsd.d.ts" />
var through = require("through2");
var path = require("path"); var path = require("path");
var pr = require("pushrocks");
var fs = require("fs");
module.exports = (jadeTemplate,mojo = undefined) => { var smartfile:any = {
//read File to string
return through.obj((file, enc, cb) => { readFileToString: (filePath) => {
var fileString;
//run callback function to signal end of plugin process. fileString = fs.readFileSync(filePath, "utf8");
return cb(null, file); return fileString;
}); }
}; };
module.exports = smartfile;

2
ts/test.ts Normal file
View File

@ -0,0 +1,2 @@
var smartfile = require("./index.js");
console.log(smartfile.readFileToString("./test/mytest.txt"));