added requireReload function

This commit is contained in:
Philipp Kunz 2015-12-08 20:33:13 +01:00
parent f1d89beb06
commit c0ee2996ce
7 changed files with 33 additions and 5 deletions

View File

@ -8,7 +8,8 @@ var SmartfilePlugins;
path: require("path"), path: require("path"),
vinyl: require("vinyl"), vinyl: require("vinyl"),
vinylFile: require("vinyl-file"), vinylFile: require("vinyl-file"),
yaml: require("js-yaml") yaml: require("js-yaml"),
requireReload: require("require-reload")
}; };
return plugins; return plugins;
}; };
@ -67,12 +68,24 @@ var SmartfileVinyl;
objectArg.readFileToVinyl = readFileToVinyl; objectArg.readFileToVinyl = readFileToVinyl;
}; };
})(SmartfileVinyl || (SmartfileVinyl = {})); })(SmartfileVinyl || (SmartfileVinyl = {}));
/// <reference path="./index.ts" />
var SmartfileRequire;
(function (SmartfileRequire) {
var requireReload = function (path) {
return plugins.requireReload(path);
};
SmartfileRequire.init = function (objectArg) {
objectArg.requireReload = requireReload;
};
})(SmartfileRequire || (SmartfileRequire = {}));
/// <reference path="./typings/tsd.d.ts" /> /// <reference path="./typings/tsd.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" />
/// <reference path="./smartfile.require.ts" />
var plugins = SmartfilePlugins.init(); var plugins = SmartfilePlugins.init();
var smartfile = {}; var smartfile = {};
SmartfileSimple.init(smartfile); SmartfileSimple.init(smartfile);
SmartfileVinyl.init(smartfile); SmartfileVinyl.init(smartfile);
SmartfileRequire.init(smartfile);
module.exports = smartfile; module.exports = smartfile;

View File

@ -27,8 +27,8 @@
"dependencies": { "dependencies": {
"beautylog": "1.0.6", "beautylog": "1.0.6",
"fs-extra": "0.26.2", "fs-extra": "0.26.2",
"install": "^0.4.0",
"js-yaml": "3.4.6", "js-yaml": "3.4.6",
"require-reload": "0.2.2",
"vinyl": "^1.1.0", "vinyl": "^1.1.0",
"vinyl-file": "^1.3.0" "vinyl-file": "^1.3.0"
}, },

View File

@ -6,3 +6,4 @@ console.log(smartfile.readFileToObject("./test/mytest.yaml"));
console.log(smartfile.readFileToObject("./test/mytest.json")); console.log(smartfile.readFileToObject("./test/mytest.json"));
console.log(smartfile.readFileToVinyl("./test/mytest.json")); console.log(smartfile.readFileToVinyl("./test/mytest.json"));
//var thisIsAnError = smartfile.readFileToObject("./test/mytestDoesNotExist.json"); //var thisIsAnError = smartfile.readFileToObject("./test/mytestDoesNotExist.json");
beautylog.success("Test passed!");

View File

@ -2,12 +2,14 @@
/// <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" />
/// <reference path="./smartfile.require.ts" />
var plugins = SmartfilePlugins.init(); var plugins = SmartfilePlugins.init();
var smartfile:any = {}; var smartfile:any = {};
SmartfileSimple.init(smartfile); SmartfileSimple.init(smartfile);
SmartfileVinyl.init(smartfile); SmartfileVinyl.init(smartfile);
SmartfileRequire.init(smartfile);

View File

@ -7,7 +7,8 @@ module SmartfilePlugins {
path: require("path"), path: require("path"),
vinyl: require("vinyl"), vinyl: require("vinyl"),
vinylFile: require("vinyl-file"), vinylFile: require("vinyl-file"),
yaml: require("js-yaml") yaml: require("js-yaml"),
requireReload: require("require-reload")
}; };
return plugins; return plugins;
} }

10
ts/smartfile.require.ts Normal file
View File

@ -0,0 +1,10 @@
/// <reference path="./index.ts" />
module SmartfileRequire {
var requireReload = function(path:string){
return plugins.requireReload(path);
};
export var init = function(objectArg){
objectArg.requireReload = requireReload;
}
}

View File

@ -6,3 +6,4 @@ console.log(smartfile.readFileToObject("./test/mytest.yaml"));
console.log(smartfile.readFileToObject("./test/mytest.json")); console.log(smartfile.readFileToObject("./test/mytest.json"));
console.log(smartfile.readFileToVinyl("./test/mytest.json")); console.log(smartfile.readFileToVinyl("./test/mytest.json"));
//var thisIsAnError = smartfile.readFileToObject("./test/mytestDoesNotExist.json"); //var thisIsAnError = smartfile.readFileToObject("./test/mytestDoesNotExist.json");
beautylog.success("Test passed!");