tests running though, can now handle local and remote files
This commit is contained in:
parent
34d38cd3d4
commit
4a8df9c12f
11
dist/index.js
vendored
11
dist/index.js
vendored
@ -1,15 +1,16 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
"use strict";
|
||||
var SmartfileChecks = require("./smartfile.checks");
|
||||
var SmartfileRead = require("./smartfile.read");
|
||||
var SmartfileFsaction = require("./smartfile.fsaction");
|
||||
var SmartfileLocal = require("./smartfile.local");
|
||||
var SmartfileRemote = require("./smartfile.remote");
|
||||
var smartfile = {
|
||||
copy: SmartfileSimple.copy,
|
||||
fsaction: SmartfileFsaction,
|
||||
checks: SmartfileChecks,
|
||||
read: SmartfileRead,
|
||||
local: SmartfileLocal,
|
||||
remote: SmartfileRemote,
|
||||
requireReload: SmartfileSimple.requireReload
|
||||
requireReload: SmartfileLocal.requireReload
|
||||
};
|
||||
module.exports = smartfile;
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLDRDQUE0Qzs7QUFHNUMsSUFBTyxlQUFlLFdBQVcsb0JBQW9CLENBQUMsQ0FBQztBQUV2RCxJQUFPLGFBQWEsV0FBVyxrQkFBa0IsQ0FBQyxDQUFDO0FBQ25ELElBQU8sZUFBZSxXQUFXLG9CQUFvQixDQUFDLENBQUM7QUFHdkQsSUFBSSxTQUFTLEdBQU87SUFDaEIsSUFBSSxFQUFFLGVBQWUsQ0FBQyxJQUFJO0lBQzFCLE1BQU0sRUFBRSxlQUFlO0lBQ3ZCLElBQUksRUFBRSxhQUFhO0lBQ25CLE1BQU0sRUFBRSxlQUFlO0lBQ3ZCLGFBQWEsRUFBRSxlQUFlLENBQUMsYUFBYTtDQUMvQyxDQUFDO0FBRUYsaUJBQVMsU0FBUyxDQUFDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiLy8vIDxyZW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c21hcnRmaWxlO1xuIl0sInNvdXJjZVJvb3QiOiIvc291cmNlLyJ9
|
||||
|
69
dist/smartfile.local.js
vendored
Normal file
69
dist/smartfile.local.js
vendored
Normal file
@ -0,0 +1,69 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
"use strict";
|
||||
var plugins = require("./smartfile.plugins");
|
||||
exports.toFS = function (options, cb) {
|
||||
if (cb === void 0) { cb = undefined; }
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @param filePath
|
||||
* @param fileTypeArg
|
||||
* @returns {any}
|
||||
*/
|
||||
exports.toObjectSync = function (filePath, fileTypeArg) {
|
||||
if (fileTypeArg === void 0) { fileTypeArg = undefined; }
|
||||
var fileType;
|
||||
if (typeof fileTypeArg == "undefined") {
|
||||
fileType = plugins.path.extname(filePath);
|
||||
}
|
||||
else {
|
||||
fileType = fileTypeArg;
|
||||
}
|
||||
fileType = fileType.replace(/\.([a-z]*)/, "$1"); //remove . form fileType
|
||||
switch (fileType) {
|
||||
case "yml":
|
||||
case "yaml":
|
||||
try {
|
||||
return plugins.yaml.safeLoad(plugins.fs.readFileSync(filePath, 'utf8'));
|
||||
}
|
||||
catch (e) {
|
||||
plugins.beautylog.error("check that " + filePath.blue + " points to a valid file");
|
||||
}
|
||||
break;
|
||||
case "json":
|
||||
return plugins.fs.readJsonSync(filePath, {});
|
||||
default:
|
||||
plugins.beautylog.error("file type " + fileType.blue + " not supported");
|
||||
break;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* reads a file content to a String
|
||||
* @param filePath
|
||||
* @returns {string|Buffer|any}
|
||||
*/
|
||||
exports.toStringSync = function (filePath) {
|
||||
var fileString;
|
||||
fileString = plugins.fs.readFileSync(filePath, "utf8");
|
||||
return fileString;
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @param filePathArg
|
||||
* @param options
|
||||
* @returns {number}
|
||||
*/
|
||||
exports.toVinylSync = function (filePathArg, options) {
|
||||
if (options === void 0) { options = {}; }
|
||||
return plugins.vinylFile.readSync(filePathArg, options);
|
||||
};
|
||||
/**
|
||||
* lets you reload files hot.
|
||||
* @param path
|
||||
* @returns {any}
|
||||
*/
|
||||
exports.requireReload = function (path) {
|
||||
return plugins.requireReload(path);
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5sb2NhbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSw0Q0FBNEM7O0FBRTVDLElBQU8sT0FBTyxXQUFXLHFCQUFxQixDQUFDLENBQUM7QUFFckMsWUFBSSxHQUFHLFVBQVMsT0FBbUMsRUFBRSxFQUFZO0lBQVosa0JBQVksR0FBWixjQUFZO0FBRTVFLENBQUMsQ0FBQztBQUVGOzs7OztHQUtHO0FBQ1Esb0JBQVksR0FBRyxVQUFTLFFBQVEsRUFBQyxXQUF1QjtJQUF2QiwyQkFBdUIsR0FBdkIsdUJBQXVCO0lBQy9ELElBQUksUUFBUSxDQUFDO0lBQ2IsRUFBRSxDQUFDLENBQUMsT0FBTyxXQUFXLElBQUksV0FBVyxDQUFDLENBQUMsQ0FBQztRQUNwQyxRQUFRLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFDLENBQUM7SUFDOUMsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0osUUFBUSxHQUFHLFdBQVcsQ0FBQztJQUMzQixDQUFDO0lBQ0QsUUFBUSxHQUFHLFFBQVEsQ0FBQyxPQUFPLENBQUMsWUFBWSxFQUFDLElBQUksQ0FBQyxDQUFDLENBQUMsd0JBQXdCO0lBQ3hFLE1BQU0sQ0FBQyxDQUFDLFFBQVEsQ0FBQyxDQUFDLENBQUM7UUFDZixLQUFLLEtBQUssQ0FBRTtRQUNaLEtBQUssTUFBTTtZQUNQLElBQUksQ0FBQztnQkFDRCxNQUFNLENBQUMsT0FBTyxDQUFDLElBQUksQ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vbnNcbiAqIEByZXR1cm5zIHtudW1iZXJ9XG4gKi9cbmV4cG9ydCBsZXQgdG9WaW55bFN5bmMgPSBmdW5jdGlvbihmaWxlUGF0aEFyZyxvcHRpb25zID0ge30pIHtcbiAgICByZXR1cm4gcGx1Z2lucy52aW55bEZpbGUucmVhZFN5bmMoZmlsZVBhdGhBcmcsb3B0aW9ucyk7XG59O1xuXG4vKipcbiAqIGxldHMgeW91IHJlbG9hZCBmaWxlcyBob3QuXG4gKiBAcGFyYW0gcGF0aFxuICogQHJldHVybnMge2FueX1cbiAqL1xuZXhwb3J0IGxldCByZXF1aXJlUmVsb2FkID0gZnVuY3Rpb24ocGF0aDpzdHJpbmcpe1xuICAgIHJldHVybiBwbHVnaW5zLnJlcXVpcmVSZWxvYWQocGF0aCk7XG59OyJdLCJzb3VyY2VSb290IjoiL3NvdXJjZS8ifQ==
|
54
dist/smartfile.remote.js
vendored
54
dist/smartfile.remote.js
vendored
@ -1,29 +1,45 @@
|
||||
"use strict";
|
||||
exports.toVar = function (options, cb) {
|
||||
var bodyString;
|
||||
request.get(options.from, function (error, response, body) {
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
var plugins = require("./smartfile.plugins");
|
||||
exports.toString = function (fromArg) {
|
||||
var done = plugins.q.defer();
|
||||
plugins.request.get(fromArg, function (error, response, bodyString) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
bodyString = body;
|
||||
console.log('successfully requested' + options.from);
|
||||
if (options.parseJson = true) {
|
||||
var jsonObject = JSON.parse(bodyString);
|
||||
return jsonObject;
|
||||
}
|
||||
;
|
||||
done.resolve(bodyString);
|
||||
}
|
||||
else {
|
||||
console.log('could not get get remote file from ' + options.from);
|
||||
return bodyString = 'could not get file';
|
||||
plugins.beautylog.error('could not get get remote file from ' + fromArg);
|
||||
bodyString = undefined;
|
||||
done.reject(bodyString);
|
||||
}
|
||||
;
|
||||
});
|
||||
return bodyString;
|
||||
return done.promise;
|
||||
};
|
||||
exports.toFS = function (options, cb) {
|
||||
if (cb === void 0) { cb = undefined; }
|
||||
var stream = request(options.from).pipe(fs.createWriteStream(options.toPath));
|
||||
if (cb != undefined)
|
||||
stream.on('finish', cb);
|
||||
exports.toObject = function (fromArg) {
|
||||
var done = plugins.q.defer();
|
||||
plugins.request.get(fromArg, function (error, response, bodyString) {
|
||||
var jsonObject;
|
||||
if (!error && response.statusCode == 200) {
|
||||
jsonObject = JSON.parse(bodyString);
|
||||
done.resolve(jsonObject);
|
||||
}
|
||||
else {
|
||||
console.log('could not get remote file from ' + fromArg);
|
||||
jsonObject = undefined;
|
||||
done.reject(jsonObject);
|
||||
}
|
||||
;
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
exports.toFs = function (from, toPath) {
|
||||
var done = plugins.q.defer();
|
||||
var stream = plugins.request(from).pipe(plugins.fs.createWriteStream(toPath));
|
||||
stream.on('finish', function () {
|
||||
done.resolve(toPath);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZmlsZS5yZW1vdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUdXLGFBQUssR0FBRyxVQUFDLE9BQXdDLEVBQUUsRUFBRTtJQUM1RCxJQUFJLFVBQWlCLENBQUM7SUFDdEIsT0FBTyxDQUFDLEdBQUcsQ0FBQyxPQUFPLENBQUMsSUFBSSxFQUFFLFVBQVUsS0FBSyxFQUFFLFFBQVEsRUFBRSxJQUFJO1FBQ3JELEVBQUUsQ0FBQyxDQUFDLENBQUMsS0FBSyxJQUFJLFFBQVEsQ0FBQyxVQUFVLElBQUksR0FBRyxDQUFDLENBQUMsQ0FBQztZQUN2QyxVQUFVLEdBQUcsSUFBSSxDQUFDO1lBQ2xCLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDO1lBQ3JELEVB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lLyJ9
|
||||
|
@ -26,8 +26,8 @@
|
||||
"homepage": "https://github.com/pushrocks/smartfile",
|
||||
"dependencies": {
|
||||
"beautylog": "3.1.2",
|
||||
"fs-extra": "0.26.5",
|
||||
"js-yaml": "3.5.4",
|
||||
"fs-extra": "0.26.7",
|
||||
"js-yaml": "3.5.5",
|
||||
"q": "1.4.1",
|
||||
"request": "^2.69.0",
|
||||
"require-reload": "0.2.2",
|
||||
@ -36,7 +36,7 @@
|
||||
"vinyl-file": "2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"npmts": "3.4.1",
|
||||
"npmts": "3.5.0",
|
||||
"should": "^8.2.2"
|
||||
}
|
||||
}
|
||||
|
94
test/test.js
94
test/test.js
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC5C,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACrC,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/B,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAE7B,QAAQ,CAAC,WAAW,EAAC;IACjB,QAAQ,CAAC,mBAAmB,CAAC,MAAM,EAAC;QAChC,EAAE,CAAC,gCAAgC,EAAC;YAChC,MAAM,CAAC,KAAK,CACR,SAAS,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,EAC/C,sBAAsB,CACzB,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,mBAAmB,CAAC,MAAM,EAAC;QAChC,EAAE,CAAC,iBAAiB,GAAG,OAAO,CAAC,IAAI,GAAG,oBAAoB,EAAC;YACvD,IAAI,QAAQ,GAAG,SAAS,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC;YAChE,QAAQ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CAAC,CAAC,CAAC;YACH,EAAE,CAAC,gDAAgD,EAAC,UAAS,IAAI;gBAC7D,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,qCAAqC,CAAC;qBAC3D,IAAI,CAAC;oBACF,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;gBACxD,CAAC,EAAC;oBACE,IAAI,EAAE,CAAC;gBACX,CAAC,CAAC,CAAA;YACV,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAC"}
|
108
test/test.ts
108
test/test.ts
@ -4,39 +4,7 @@ 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 state unknown file type for unknown file types",function(){
|
||||
var testData = smartfile.readFileToObject("./test/mytest.txt");
|
||||
});
|
||||
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();
|
||||
|
||||
});
|
||||
});
|
||||
describe("smartfile".yellow,function(){
|
||||
describe(".checks".yellow,function(){
|
||||
describe(".fileExistsSync".yellow,function(){
|
||||
it("should return an accurate boolean",function(){
|
||||
@ -52,15 +20,71 @@ describe("smartfile",function(){
|
||||
});
|
||||
})
|
||||
});
|
||||
describe("copy",function(){
|
||||
it("should copy a directory",function(){
|
||||
smartfile.copy("./test/testfolder/","./test/assets/")
|
||||
});
|
||||
it("should copy a file",function(){
|
||||
smartfile.copy("./test/mytest.yaml","./test/assets/")
|
||||
});
|
||||
it("should copy a file and rename it",function(){
|
||||
smartfile.copy("./test/mytest.yaml","./test/assets/mytestRenamed.yaml")
|
||||
describe(".fsaction".yellow,function(){
|
||||
describe(".copy()".yellow,function(){
|
||||
it("should copy a directory",function(){
|
||||
smartfile.fsaction.copy("./test/testfolder/","./test/assets/")
|
||||
});
|
||||
it("should copy a file",function(){
|
||||
smartfile.fsaction.copy("./test/mytest.yaml","./test/assets/")
|
||||
});
|
||||
it("should copy a file and rename it",function(){
|
||||
smartfile.fsaction.copy("./test/mytest.yaml","./test/assets/mytestRenamed.yaml")
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(".local".yellow,function(){
|
||||
describe(".toStringSync()".yellow,function(){
|
||||
it("should read a file to a string",function(){
|
||||
should.equal(
|
||||
smartfile.local.toStringSync("./test/mytest.txt"),
|
||||
"Some TestString &&%$"
|
||||
);
|
||||
});
|
||||
});
|
||||
describe(".toObjectSync()".yellow,function(){
|
||||
it("should read an " + ".yaml".blue + " file to an object",function(){
|
||||
var testData = smartfile.local.toObjectSync("./test/mytest.yaml");
|
||||
testData.should.have.property("key1","this works");
|
||||
testData.should.have.property("key2","this works too");
|
||||
|
||||
});
|
||||
it("should state unknown file type for unknown file types",function(){
|
||||
var testData = smartfile.local.toObjectSync("./test/mytest.txt");
|
||||
});
|
||||
it("should read an " + ".json".blue + " file to an object",function(){
|
||||
var testData = smartfile.local.toObjectSync("./test/mytest.json");
|
||||
testData.should.have.property("key1","this works");
|
||||
testData.should.have.property("key2","this works too");
|
||||
|
||||
});
|
||||
});
|
||||
describe(".toVinylSync".yellow,function(){
|
||||
it("should read an " + ".json OR .yaml".blue + " file to an " + "vinyl file object".cyan,function(){
|
||||
var testData = smartfile.local.toVinylSync("./test/mytest.json");
|
||||
(vinyl.isVinyl(testData)).should.be.true();
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
describe(".remote",function(){
|
||||
describe(".toString()",function(){
|
||||
it("should load a remote file to a variable",function(done){
|
||||
this.timeout(5000);
|
||||
smartfile.remote.toString("https://raw.githubusercontent.com/pushrocks/smartfile/master/test/mytest.txt")
|
||||
.then(function(responseString){
|
||||
should.equal(responseString,"Some TestString &&%$");
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("should reject a Promise when the link is false",function(done){
|
||||
smartfile.remote.toString("https://push.rocks/doesnotexist.txt")
|
||||
.then(function(){
|
||||
throw new Error("this test should not be resolved");
|
||||
},function(){
|
||||
done();
|
||||
})
|
||||
});
|
||||
});
|
||||
})
|
||||
});
|
||||
|
@ -3,16 +3,16 @@
|
||||
import plugins = require("./smartfile.plugins");
|
||||
import SmartfileChecks = require("./smartfile.checks");
|
||||
import SmartfileFsaction = require("./smartfile.fsaction");
|
||||
import SmartfileRead = require("./smartfile.read");
|
||||
import SmartfileLocal = require("./smartfile.local");
|
||||
import SmartfileRemote = require("./smartfile.remote");
|
||||
|
||||
|
||||
var smartfile:any = {
|
||||
copy: SmartfileSimple.copy,
|
||||
fsaction: SmartfileFsaction,
|
||||
checks: SmartfileChecks,
|
||||
read: SmartfileRead,
|
||||
local: SmartfileLocal,
|
||||
remote: SmartfileRemote,
|
||||
requireReload: SmartfileSimple.requireReload
|
||||
requireReload: SmartfileLocal.requireReload
|
||||
};
|
||||
|
||||
export = smartfile;
|
||||
|
@ -12,7 +12,7 @@ export let toFS = function(options:{from:string,toPath:string}, cb=undefined){
|
||||
* @param fileTypeArg
|
||||
* @returns {any}
|
||||
*/
|
||||
export let toObject = function(filePath,fileTypeArg = undefined) {
|
||||
export let toObjectSync = function(filePath,fileTypeArg = undefined) {
|
||||
let fileType;
|
||||
if (typeof fileTypeArg == "undefined") {
|
||||
fileType = plugins.path.extname(filePath);
|
||||
@ -42,7 +42,7 @@ export let toObject = function(filePath,fileTypeArg = undefined) {
|
||||
* @param filePath
|
||||
* @returns {string|Buffer|any}
|
||||
*/
|
||||
export let toString = function(filePath) {
|
||||
export let toStringSync = function(filePath) {
|
||||
let fileString;
|
||||
fileString = plugins.fs.readFileSync(filePath, "utf8");
|
||||
return fileString;
|
||||
@ -54,7 +54,7 @@ export let toString = function(filePath) {
|
||||
* @param options
|
||||
* @returns {number}
|
||||
*/
|
||||
export let toVinyl = function(filePathArg,options = {}) {
|
||||
export let toVinylSync = function(filePathArg,options = {}) {
|
||||
return plugins.vinylFile.readSync(filePathArg,options);
|
||||
};
|
||||
|
@ -1,26 +1,41 @@
|
||||
/// <reference path="./typings/main.d.ts" />
|
||||
import plugins = require("./smartfile.plugins");
|
||||
|
||||
export let toVar = (options:{from:string,parseJson?:boolean}, cb):any => {
|
||||
var bodyString:string;
|
||||
request.get(options.from, function (error, response, body) {
|
||||
export let toString = (fromArg:string) => {
|
||||
let done = plugins.q.defer();
|
||||
plugins.request.get(fromArg, function (error, response, bodyString) {
|
||||
if (!error && response.statusCode == 200) {
|
||||
bodyString = body;
|
||||
console.log('successfully requested' + options.from);
|
||||
if (options.parseJson = true) {
|
||||
var jsonObject = JSON.parse(bodyString);
|
||||
return jsonObject;
|
||||
};
|
||||
done.resolve(bodyString);
|
||||
} else {
|
||||
console.log('could not get get remote file from ' + options.from);
|
||||
return bodyString = 'could not get file'
|
||||
plugins.beautylog.error('could not get get remote file from ' + fromArg);
|
||||
bodyString = undefined;
|
||||
done.reject(bodyString);
|
||||
};
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
return bodyString;
|
||||
},
|
||||
export let toObject = function(fromArg:string){
|
||||
let done = plugins.q.defer();
|
||||
plugins.request.get(fromArg, function (error, response, bodyString) {
|
||||
let jsonObject;
|
||||
if (!error && response.statusCode == 200) {
|
||||
jsonObject = JSON.parse(bodyString);
|
||||
done.resolve(jsonObject);
|
||||
} else {
|
||||
console.log('could not get remote file from ' + fromArg);
|
||||
jsonObject = undefined;
|
||||
done.reject(jsonObject);
|
||||
};
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
export let toFS = function(options:{from:string,toPath:string}, cb=undefined) {
|
||||
var stream = request(options.from).pipe(fs.createWriteStream(options.toPath));
|
||||
if (cb != undefined) stream.on('finish',cb);
|
||||
}
|
||||
export let toFs = function(from:string,toPath:string) {
|
||||
var done = plugins.q.defer();
|
||||
var stream = plugins.request(from).pipe(plugins.fs.createWriteStream(toPath));
|
||||
stream.on('finish',function(){
|
||||
done.resolve(toPath);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
Loading…
Reference in New Issue
Block a user