added checks
This commit is contained in:
parent
c5cfa79f14
commit
3511f36b67
@ -1,11 +1,9 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- '4.1'
|
- '4.2.4'
|
||||||
before_install:
|
|
||||||
- npm install -g tsd
|
|
||||||
deploy:
|
deploy:
|
||||||
provider: npm
|
provider: npm
|
||||||
email: npm@smart-coordination.com
|
email: npm@lossless.digital
|
||||||
api_key:
|
api_key:
|
||||||
secure: 3RdzAcS9d6sLJs3tHM2uCVU2wV2NsKiLiYWue98DevgijIqTFDHtYuoP29p7fbB4SV87JRbTK1y41QM2u/CCjnbB+mrAUg/Pn08dTibmzi9liom67sLczIPD4eZeMznXPRaddESQdzqrtQfc/6P+1JQO7XWexLNebgYtMrUzYcOrHPWf/Uktk2cKiYfrO8piSR+HOFh2rzC5HjVZ/7fKDIa9bqTlBETkNc7s2NgB++jKRF9LNMVGI/9EmxjBzSSE1juOz26Ahp4+/+P3Lc5LngnTFOYsPoW5iWNY+AQltZxhu9K+rrtfn90rmQDnO7RCGO5yZgMS2+0UjJedwV+4ancU3nzoNmiuoIL7DjQ7NQlt0QKMmIqZuBFBc3tdxqotxNoJDk8/Ui0yfHWzJz0Fd22OI+VdTWNH1y5Vyywsql6wwkl2+Da1WhZf/Mn2gPgLPI0lssPTIl/u3Bey+167tZ3HvX0yqlvPO/JbqK02+5VrRBaV67vT00DG+dh4nnwqcX14Umx2a3JHt3tSGkDnDKpsLbvqjhPhkMRsCIloju+wMnyKjtScMZW+2FeO2n4PgbjNhF+5SG8pDmTS8p0Vy7iohUOiGIJty7K/1r6sQ1FNluhO5Ol3mBDs6wjg6S5QCSNL9eylpV52FV0UX4cRCijmzso+n48I2BbSwjghTB8=
|
secure: 3RdzAcS9d6sLJs3tHM2uCVU2wV2NsKiLiYWue98DevgijIqTFDHtYuoP29p7fbB4SV87JRbTK1y41QM2u/CCjnbB+mrAUg/Pn08dTibmzi9liom67sLczIPD4eZeMznXPRaddESQdzqrtQfc/6P+1JQO7XWexLNebgYtMrUzYcOrHPWf/Uktk2cKiYfrO8piSR+HOFh2rzC5HjVZ/7fKDIa9bqTlBETkNc7s2NgB++jKRF9LNMVGI/9EmxjBzSSE1juOz26Ahp4+/+P3Lc5LngnTFOYsPoW5iWNY+AQltZxhu9K+rrtfn90rmQDnO7RCGO5yZgMS2+0UjJedwV+4ancU3nzoNmiuoIL7DjQ7NQlt0QKMmIqZuBFBc3tdxqotxNoJDk8/Ui0yfHWzJz0Fd22OI+VdTWNH1y5Vyywsql6wwkl2+Da1WhZf/Mn2gPgLPI0lssPTIl/u3Bey+167tZ3HvX0yqlvPO/JbqK02+5VrRBaV67vT00DG+dh4nnwqcX14Umx2a3JHt3tSGkDnDKpsLbvqjhPhkMRsCIloju+wMnyKjtScMZW+2FeO2n4PgbjNhF+5SG8pDmTS8p0Vy7iohUOiGIJty7K/1r6sQ1FNluhO5Ol3mBDs6wjg6S5QCSNL9eylpV52FV0UX4cRCijmzso+n48I2BbSwjghTB8=
|
||||||
on:
|
on:
|
||||||
|
5
index.d.ts
vendored
5
index.d.ts
vendored
@ -4,12 +4,16 @@ declare module SmartfilePlugins {
|
|||||||
beautylog: any;
|
beautylog: any;
|
||||||
fs: any;
|
fs: any;
|
||||||
path: any;
|
path: any;
|
||||||
|
q: any;
|
||||||
vinyl: any;
|
vinyl: any;
|
||||||
vinylFile: any;
|
vinylFile: any;
|
||||||
yaml: any;
|
yaml: any;
|
||||||
requireReload: any;
|
requireReload: any;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
declare module SmartfileCheck {
|
||||||
|
var init: (objectArg: any) => void;
|
||||||
|
}
|
||||||
declare module SmartfileSimple {
|
declare module SmartfileSimple {
|
||||||
var init: (objectArg: any) => void;
|
var init: (objectArg: any) => void;
|
||||||
}
|
}
|
||||||
@ -23,6 +27,7 @@ declare var plugins: {
|
|||||||
beautylog: any;
|
beautylog: any;
|
||||||
fs: any;
|
fs: any;
|
||||||
path: any;
|
path: any;
|
||||||
|
q: any;
|
||||||
vinyl: any;
|
vinyl: any;
|
||||||
vinylFile: any;
|
vinylFile: any;
|
||||||
yaml: any;
|
yaml: any;
|
||||||
|
30
index.js
30
index.js
@ -8,6 +8,7 @@ var SmartfilePlugins;
|
|||||||
beautylog: require("beautylog"),
|
beautylog: require("beautylog"),
|
||||||
fs: require("fs-extra"),
|
fs: require("fs-extra"),
|
||||||
path: require("path"),
|
path: require("path"),
|
||||||
|
q: require("q"),
|
||||||
vinyl: require("vinyl"),
|
vinyl: require("vinyl"),
|
||||||
vinylFile: require("vinyl-file"),
|
vinylFile: require("vinyl-file"),
|
||||||
yaml: require("js-yaml"),
|
yaml: require("js-yaml"),
|
||||||
@ -17,6 +18,33 @@ var SmartfilePlugins;
|
|||||||
};
|
};
|
||||||
})(SmartfilePlugins || (SmartfilePlugins = {}));
|
})(SmartfilePlugins || (SmartfilePlugins = {}));
|
||||||
/// <reference path="./index.ts" />
|
/// <reference path="./index.ts" />
|
||||||
|
var SmartfileCheck;
|
||||||
|
(function (SmartfileCheck) {
|
||||||
|
var checks = {
|
||||||
|
fileExistsSync: function (filePath) {
|
||||||
|
var fileExistsBool = false;
|
||||||
|
try {
|
||||||
|
plugins.fs.readFileSync(filePath);
|
||||||
|
fileExistsBool = true;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
fileExistsBool = false;
|
||||||
|
}
|
||||||
|
return fileExistsBool;
|
||||||
|
},
|
||||||
|
fileExists: function (filePath) {
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) {
|
||||||
|
err ? done.reject() : done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
SmartfileCheck.init = function (objectArg) {
|
||||||
|
objectArg.checks = checks;
|
||||||
|
};
|
||||||
|
})(SmartfileCheck || (SmartfileCheck = {}));
|
||||||
|
/// <reference path="./index.ts" />
|
||||||
var SmartfileSimple;
|
var SmartfileSimple;
|
||||||
(function (SmartfileSimple) {
|
(function (SmartfileSimple) {
|
||||||
/**
|
/**
|
||||||
@ -82,11 +110,13 @@ var SmartfileRequire;
|
|||||||
})(SmartfileRequire || (SmartfileRequire = {}));
|
})(SmartfileRequire || (SmartfileRequire = {}));
|
||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
/// <reference path="./smartfile.plugins.ts" />
|
/// <reference path="./smartfile.plugins.ts" />
|
||||||
|
/// <reference path="./smartfile.check.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" />
|
/// <reference path="./smartfile.require.ts" />
|
||||||
var plugins = SmartfilePlugins.init();
|
var plugins = SmartfilePlugins.init();
|
||||||
var smartfile = {};
|
var smartfile = {};
|
||||||
|
SmartfileCheck.init(smartfile);
|
||||||
SmartfileSimple.init(smartfile);
|
SmartfileSimple.init(smartfile);
|
||||||
SmartfileVinyl.init(smartfile);
|
SmartfileVinyl.init(smartfile);
|
||||||
SmartfileRequire.init(smartfile);
|
SmartfileRequire.init(smartfile);
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
"beautylog": "2.0.6",
|
"beautylog": "2.0.6",
|
||||||
"fs-extra": "0.26.5",
|
"fs-extra": "0.26.5",
|
||||||
"js-yaml": "3.5.2",
|
"js-yaml": "3.5.2",
|
||||||
|
"q": "^1.4.1",
|
||||||
"require-reload": "0.2.2",
|
"require-reload": "0.2.2",
|
||||||
"vinyl": "1.1.1",
|
"vinyl": "1.1.1",
|
||||||
"vinyl-file": "2.0.0"
|
"vinyl-file": "2.0.0"
|
||||||
|
15
test/test.js
15
test/test.js
@ -27,4 +27,19 @@ describe("smartfile", function () {
|
|||||||
(vinyl.isVinyl(testData)).should.be.true();
|
(vinyl.isVinyl(testData)).should.be.true();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe(".checks".yellow, function () {
|
||||||
|
describe(".fileExistsSync".yellow, function () {
|
||||||
|
it("should return an accurate boolean", function () {
|
||||||
|
(smartfile.checks.fileExistsSync("./test/mytest.json")).should.be.true();
|
||||||
|
(smartfile.checks.fileExistsSync("./test/notthere.json")).should.be.false();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe(".fileExists".yellow, function () {
|
||||||
|
it("should return a working promise", function () {
|
||||||
|
(smartfile.checks.fileExists("./test/mytest.json")).should.be.Promise();
|
||||||
|
(smartfile.checks.fileExists("./test/mytest.json")).should.be.fulfilled();
|
||||||
|
(smartfile.checks.fileExists("./test/notthere.json")).should.not.be.fulfilled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/// <reference path="./typings/main.d.ts" />
|
/// <reference path="./typings/main.d.ts" />
|
||||||
/// <reference path="./smartfile.plugins.ts" />
|
/// <reference path="./smartfile.plugins.ts" />
|
||||||
|
/// <reference path="./smartfile.check.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" />
|
/// <reference path="./smartfile.require.ts" />
|
||||||
@ -7,6 +8,7 @@ var plugins = SmartfilePlugins.init();
|
|||||||
|
|
||||||
|
|
||||||
var smartfile:any = {};
|
var smartfile:any = {};
|
||||||
|
SmartfileCheck.init(smartfile);
|
||||||
SmartfileSimple.init(smartfile);
|
SmartfileSimple.init(smartfile);
|
||||||
SmartfileVinyl.init(smartfile);
|
SmartfileVinyl.init(smartfile);
|
||||||
SmartfileRequire.init(smartfile);
|
SmartfileRequire.init(smartfile);
|
||||||
|
26
ts/smartfile.check.ts
Normal file
26
ts/smartfile.check.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
module SmartfileCheck {
|
||||||
|
var checks = {
|
||||||
|
fileExistsSync: function(filePath):boolean {
|
||||||
|
var fileExistsBool:boolean = false;
|
||||||
|
try {
|
||||||
|
plugins.fs.readFileSync(filePath)
|
||||||
|
fileExistsBool = true
|
||||||
|
}
|
||||||
|
catch(err){
|
||||||
|
fileExistsBool = false;
|
||||||
|
}
|
||||||
|
return fileExistsBool;
|
||||||
|
},
|
||||||
|
fileExists: function(filePath){
|
||||||
|
var done = plugins.q.defer();
|
||||||
|
plugins.fs.access(filePath, plugins.fs.R_OK, function (err) {
|
||||||
|
err ? done.reject() : done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
export var init = function(objectArg){
|
||||||
|
objectArg.checks = checks;
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ module SmartfilePlugins {
|
|||||||
beautylog: require("beautylog"),
|
beautylog: require("beautylog"),
|
||||||
fs: require("fs-extra"),
|
fs: require("fs-extra"),
|
||||||
path: require("path"),
|
path: require("path"),
|
||||||
|
q: require("q"),
|
||||||
vinyl: require("vinyl"),
|
vinyl: require("vinyl"),
|
||||||
vinylFile: require("vinyl-file"),
|
vinylFile: require("vinyl-file"),
|
||||||
yaml: require("js-yaml"),
|
yaml: require("js-yaml"),
|
||||||
|
15
ts/test.ts
15
ts/test.ts
@ -33,4 +33,19 @@ describe("smartfile",function(){
|
|||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe(".checks".yellow,function(){
|
||||||
|
describe(".fileExistsSync".yellow,function(){
|
||||||
|
it("should return an accurate boolean",function(){
|
||||||
|
(smartfile.checks.fileExistsSync("./test/mytest.json")).should.be.true();
|
||||||
|
(smartfile.checks.fileExistsSync("./test/notthere.json")).should.be.false();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
describe(".fileExists".yellow,function(){
|
||||||
|
it("should return a working promise",function(){
|
||||||
|
(smartfile.checks.fileExists("./test/mytest.json")).should.be.Promise();
|
||||||
|
(smartfile.checks.fileExists("./test/mytest.json")).should.be.fulfilled();
|
||||||
|
(smartfile.checks.fileExists("./test/notthere.json")).should.not.be.fulfilled();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ambientDependencies": {
|
"ambientDependencies": {
|
||||||
"browserify": "github:DefinitelyTyped/DefinitelyTyped/browserify/browserify.d.ts",
|
"browserify": "github:DefinitelyTyped/DefinitelyTyped/browserify/browserify.d.ts",
|
||||||
|
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts",
|
||||||
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
|
||||||
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts"
|
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user