add proper mocha tests and update deps
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -4,3 +4,4 @@ node_modules/
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
ts/*.js
 | 
					ts/*.js
 | 
				
			||||||
ts/*.js.map
 | 
					ts/*.js.map
 | 
				
			||||||
 | 
					ts/typings/
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										31
									
								
								index.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								index.d.ts
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					/// <reference path="ts/typings/main.d.ts" />
 | 
				
			||||||
 | 
					declare module SmartfilePlugins {
 | 
				
			||||||
 | 
					    var init: () => {
 | 
				
			||||||
 | 
					        beautylog: any;
 | 
				
			||||||
 | 
					        fs: any;
 | 
				
			||||||
 | 
					        path: any;
 | 
				
			||||||
 | 
					        vinyl: any;
 | 
				
			||||||
 | 
					        vinylFile: any;
 | 
				
			||||||
 | 
					        yaml: any;
 | 
				
			||||||
 | 
					        requireReload: any;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					declare module SmartfileSimple {
 | 
				
			||||||
 | 
					    var init: (objectArg: any) => void;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					declare module SmartfileVinyl {
 | 
				
			||||||
 | 
					    var init: (objectArg: any) => void;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					declare module SmartfileRequire {
 | 
				
			||||||
 | 
					    var init: (objectArg: any) => void;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					declare var plugins: {
 | 
				
			||||||
 | 
					    beautylog: any;
 | 
				
			||||||
 | 
					    fs: any;
 | 
				
			||||||
 | 
					    path: any;
 | 
				
			||||||
 | 
					    vinyl: any;
 | 
				
			||||||
 | 
					    vinylFile: any;
 | 
				
			||||||
 | 
					    yaml: any;
 | 
				
			||||||
 | 
					    requireReload: any;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					declare var smartfile: any;
 | 
				
			||||||
							
								
								
									
										6
									
								
								index.js
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								index.js
									
									
									
									
									
								
							@@ -1,9 +1,11 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env node
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// <reference path="./index.ts" />
 | 
					/// <reference path="./index.ts" />
 | 
				
			||||||
var SmartfilePlugins;
 | 
					var SmartfilePlugins;
 | 
				
			||||||
(function (SmartfilePlugins) {
 | 
					(function (SmartfilePlugins) {
 | 
				
			||||||
    SmartfilePlugins.init = function () {
 | 
					    SmartfilePlugins.init = function () {
 | 
				
			||||||
        var plugins = {
 | 
					        var plugins = {
 | 
				
			||||||
            beautylog: require("beautylog")("os"),
 | 
					            beautylog: require("beautylog"),
 | 
				
			||||||
            fs: require("fs-extra"),
 | 
					            fs: require("fs-extra"),
 | 
				
			||||||
            path: require("path"),
 | 
					            path: require("path"),
 | 
				
			||||||
            vinyl: require("vinyl"),
 | 
					            vinyl: require("vinyl"),
 | 
				
			||||||
@@ -78,7 +80,7 @@ var SmartfileRequire;
 | 
				
			|||||||
        objectArg.requireReload = requireReload;
 | 
					        objectArg.requireReload = requireReload;
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
})(SmartfileRequire || (SmartfileRequire = {}));
 | 
					})(SmartfileRequire || (SmartfileRequire = {}));
 | 
				
			||||||
/// <reference path="./typings/tsd.d.ts" />
 | 
					/// <reference path="./typings/main.d.ts" />
 | 
				
			||||||
/// <reference path="./smartfile.plugins.ts" />
 | 
					/// <reference path="./smartfile.plugins.ts" />
 | 
				
			||||||
/// <reference path="./smartfile.simple.ts" />
 | 
					/// <reference path="./smartfile.simple.ts" />
 | 
				
			||||||
/// <reference path="./smartfile.vinyl.ts" />
 | 
					/// <reference path="./smartfile.vinyl.ts" />
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										18
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								package.json
									
									
									
									
									
								
							@@ -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) && (node test.js)",
 | 
					    "test": "(npmts)",
 | 
				
			||||||
    "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)",
 | 
				
			||||||
    "update": "(git checkout master && git pull origin master && npm install)",
 | 
					    "update": "(git checkout master && git pull origin master && npm install)",
 | 
				
			||||||
@@ -25,16 +25,16 @@
 | 
				
			|||||||
  },
 | 
					  },
 | 
				
			||||||
  "homepage": "https://github.com/pushrocks/smartfile",
 | 
					  "homepage": "https://github.com/pushrocks/smartfile",
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
    "beautylog": "1.0.6",
 | 
					    "beautylog": "2.0.6",
 | 
				
			||||||
    "fs-extra": "0.26.2",
 | 
					    "fs-extra": "0.26.5",
 | 
				
			||||||
    "js-yaml": "3.4.6",
 | 
					    "js-yaml": "3.5.2",
 | 
				
			||||||
    "require-reload": "0.2.2",
 | 
					    "require-reload": "0.2.2",
 | 
				
			||||||
    "vinyl": "^1.1.0",
 | 
					    "vinyl": "1.1.1",
 | 
				
			||||||
    "vinyl-file": "^1.3.0"
 | 
					    "vinyl-file": "2.0.0"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "devDependencies": {
 | 
					  "devDependencies": {
 | 
				
			||||||
    "gulp": "3.9.0",
 | 
					    "beautylog": "2.0.7",
 | 
				
			||||||
    "gulp-typescript": "2.10.0",
 | 
					    "npmts": "2.0.3",
 | 
				
			||||||
    "pushrocks": "1.0.23"
 | 
					    "should": "^8.2.1"
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										9
									
								
								test.js
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								test.js
									
									
									
									
									
								
							@@ -1,9 +0,0 @@
 | 
				
			|||||||
/// <reference path="typings/tsd.d.ts" />
 | 
					 | 
				
			||||||
var smartfile = require("./index.js");
 | 
					 | 
				
			||||||
var beautylog = require("beautylog")("os");
 | 
					 | 
				
			||||||
beautylog.info(smartfile.readFileToString("./test/mytest.txt"));
 | 
					 | 
				
			||||||
console.log(smartfile.readFileToObject("./test/mytest.yaml"));
 | 
					 | 
				
			||||||
console.log(smartfile.readFileToObject("./test/mytest.json"));
 | 
					 | 
				
			||||||
console.log(smartfile.readFileToVinyl("./test/mytest.json"));
 | 
					 | 
				
			||||||
//var thisIsAnError = smartfile.readFileToObject("./test/mytestDoesNotExist.json");
 | 
					 | 
				
			||||||
beautylog.success("Test passed!");
 | 
					 | 
				
			||||||
@@ -1 +1 @@
 | 
				
			|||||||
This is some test text stored in ./test/mytest.txt -> If this is displayed when running "npm test", then the test has succeeded.
 | 
					Some TestString &&%$
 | 
				
			||||||
							
								
								
									
										30
									
								
								test/test.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								test/test.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					/// <reference path="typings/main.d.ts" />
 | 
				
			||||||
 | 
					var smartfile = require("../index.js");
 | 
				
			||||||
 | 
					var beautylog = require("beautylog");
 | 
				
			||||||
 | 
					var should = require("should");
 | 
				
			||||||
 | 
					var vinyl = require("vinyl");
 | 
				
			||||||
 | 
					describe("smartfile", function () {
 | 
				
			||||||
 | 
					    describe(".readFileToString".yellow, function () {
 | 
				
			||||||
 | 
					        it("should read a file to a string", function () {
 | 
				
			||||||
 | 
					            should.equal(smartfile.readFileToString("./test/mytest.txt"), "Some TestString &&%$");
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    describe(".readFileToObject".yellow, function () {
 | 
				
			||||||
 | 
					        it("should read an " + ".yaml".blue + " file to an object", function () {
 | 
				
			||||||
 | 
					            var testData = smartfile.readFileToObject("./test/mytest.yaml");
 | 
				
			||||||
 | 
					            testData.should.have.property("key1", "this works");
 | 
				
			||||||
 | 
					            testData.should.have.property("key2", "this works too");
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        it("should read an " + ".json".blue + " file to an object", function () {
 | 
				
			||||||
 | 
					            var testData = smartfile.readFileToObject("./test/mytest.json");
 | 
				
			||||||
 | 
					            testData.should.have.property("key1", "this works");
 | 
				
			||||||
 | 
					            testData.should.have.property("key2", "this works too");
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    describe(".readFileToVinyl".yellow, function () {
 | 
				
			||||||
 | 
					        it("should read an " + ".json OR .yaml".blue + " file to an " + "vinyl file object".cyan, function () {
 | 
				
			||||||
 | 
					            var testData = smartfile.readFileToVinyl("./test/mytest.json");
 | 
				
			||||||
 | 
					            (vinyl.isVinyl(testData)).should.be.true();
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
@@ -1,30 +0,0 @@
 | 
				
			|||||||
// import gulp
 | 
					 | 
				
			||||||
var gulp = require("gulp")
 | 
					 | 
				
			||||||
var gulpTypescript = require("gulp-typescript");
 | 
					 | 
				
			||||||
var pr = require("pushrocks");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
gulp.task('compileTS', function() {
 | 
					 | 
				
			||||||
	var stream = gulp.src('../index.ts')
 | 
					 | 
				
			||||||
	  .pipe(gulpTypescript({
 | 
					 | 
				
			||||||
	  	out: "index.js"
 | 
					 | 
				
			||||||
	  }))
 | 
					 | 
				
			||||||
	  .pipe(gulp.dest("../../"));
 | 
					 | 
				
			||||||
	return stream;
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
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');
 | 
					 | 
				
			||||||
});
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
//lets tell gulp to start with the default task.
 | 
					 | 
				
			||||||
pr.beautylog.log('Starting Gulp to compile TypeScript');
 | 
					 | 
				
			||||||
gulp.start.apply(gulp, ['default']);
 | 
					 | 
				
			||||||
@@ -1,2 +0,0 @@
 | 
				
			|||||||
# How to compile.
 | 
					 | 
				
			||||||
Make sure gulp and gulp-taypescript from npm are available. Then run the gulpfile in this directory.
 | 
					 | 
				
			||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
/// <reference path="./typings/tsd.d.ts" />
 | 
					/// <reference path="./typings/main.d.ts" />
 | 
				
			||||||
/// <reference path="./smartfile.plugins.ts" />
 | 
					/// <reference path="./smartfile.plugins.ts" />
 | 
				
			||||||
/// <reference path="./smartfile.simple.ts" />
 | 
					/// <reference path="./smartfile.simple.ts" />
 | 
				
			||||||
/// <reference path="./smartfile.vinyl.ts" />
 | 
					/// <reference path="./smartfile.vinyl.ts" />
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2,7 +2,7 @@
 | 
				
			|||||||
module SmartfilePlugins {
 | 
					module SmartfilePlugins {
 | 
				
			||||||
    export var init = function() {
 | 
					    export var init = function() {
 | 
				
			||||||
        var plugins = {
 | 
					        var plugins = {
 | 
				
			||||||
            beautylog: require("beautylog")("os"),
 | 
					            beautylog: require("beautylog"),
 | 
				
			||||||
            fs: require("fs-extra"),
 | 
					            fs: require("fs-extra"),
 | 
				
			||||||
            path: require("path"),
 | 
					            path: require("path"),
 | 
				
			||||||
            vinyl: require("vinyl"),
 | 
					            vinyl: require("vinyl"),
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										45
									
								
								ts/test.ts
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								ts/test.ts
									
									
									
									
									
								
							@@ -1,9 +1,36 @@
 | 
				
			|||||||
/// <reference path="typings/tsd.d.ts" />
 | 
					/// <reference path="typings/main.d.ts" />
 | 
				
			||||||
var smartfile = require("./index.js");
 | 
					var smartfile = require("../index.js");
 | 
				
			||||||
var beautylog = require("beautylog")("os");
 | 
					var beautylog = require("beautylog");
 | 
				
			||||||
beautylog.info(smartfile.readFileToString("./test/mytest.txt"));
 | 
					var should = require("should");
 | 
				
			||||||
console.log(smartfile.readFileToObject("./test/mytest.yaml"));
 | 
					var vinyl = require("vinyl");
 | 
				
			||||||
console.log(smartfile.readFileToObject("./test/mytest.json"));
 | 
					describe("smartfile",function(){
 | 
				
			||||||
console.log(smartfile.readFileToVinyl("./test/mytest.json"));
 | 
					    describe(".readFileToString".yellow,function(){
 | 
				
			||||||
//var thisIsAnError = smartfile.readFileToObject("./test/mytestDoesNotExist.json");
 | 
					        it("should read a file to a string",function(){
 | 
				
			||||||
beautylog.success("Test passed!");
 | 
					            should.equal(
 | 
				
			||||||
 | 
					                smartfile.readFileToString("./test/mytest.txt"),
 | 
				
			||||||
 | 
					                "Some TestString &&%$"
 | 
				
			||||||
 | 
					            );
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    describe(".readFileToObject".yellow,function(){
 | 
				
			||||||
 | 
					        it("should read an " + ".yaml".blue + " file to an object",function(){
 | 
				
			||||||
 | 
					            var testData = smartfile.readFileToObject("./test/mytest.yaml");
 | 
				
			||||||
 | 
					            testData.should.have.property("key1","this works");
 | 
				
			||||||
 | 
					            testData.should.have.property("key2","this works too");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					        it("should read an " + ".json".blue + " file to an object",function(){
 | 
				
			||||||
 | 
					            var testData = smartfile.readFileToObject("./test/mytest.json");
 | 
				
			||||||
 | 
					            testData.should.have.property("key1","this works");
 | 
				
			||||||
 | 
					            testData.should.have.property("key2","this works too");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					    describe(".readFileToVinyl".yellow,function(){
 | 
				
			||||||
 | 
					        it("should read an " + ".json OR .yaml".blue + " file to an " + "vinyl file object".cyan,function(){
 | 
				
			||||||
 | 
					            var testData = smartfile.readFileToVinyl("./test/mytest.json");
 | 
				
			||||||
 | 
					            (vinyl.isVinyl(testData)).should.be.true();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										12
									
								
								ts/tsd.json
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								ts/tsd.json
									
									
									
									
									
								
							@@ -1,12 +0,0 @@
 | 
				
			|||||||
{
 | 
					 | 
				
			||||||
  "version": "v4",
 | 
					 | 
				
			||||||
  "repo": "borisyankov/DefinitelyTyped",
 | 
					 | 
				
			||||||
  "ref": "master",
 | 
					 | 
				
			||||||
  "path": "typings",
 | 
					 | 
				
			||||||
  "bundle": "typings/tsd.d.ts",
 | 
					 | 
				
			||||||
  "installed": {
 | 
					 | 
				
			||||||
    "node/node.d.ts": {
 | 
					 | 
				
			||||||
      "commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										7
									
								
								ts/typings.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								ts/typings.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "ambientDependencies": {
 | 
				
			||||||
 | 
					    "browserify": "github:DefinitelyTyped/DefinitelyTyped/browserify/browserify.d.ts",
 | 
				
			||||||
 | 
					    "mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
 | 
				
			||||||
 | 
					    "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts"
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										2079
									
								
								ts/typings/node/node.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2079
									
								
								ts/typings/node/node.d.ts
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1
									
								
								ts/typings/tsd.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								ts/typings/tsd.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -1 +0,0 @@
 | 
				
			|||||||
/// <reference path="node/node.d.ts" />
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user