add boolean for wether configfile is present

This commit is contained in:
Phil Kunz 2016-07-18 20:29:29 +02:00
parent 540e7610af
commit ec56eb75c2
5 changed files with 28 additions and 2 deletions

1
dist/index.d.ts vendored
View File

@ -4,3 +4,4 @@ export interface IDataFor {
cwd?: string;
}
export declare let dataFor: (optionsArg: IDataFor) => any;
export declare let configFilePresent: () => boolean;

5
dist/index.js vendored
View File

@ -44,4 +44,7 @@ exports.dataFor = (optionsArg) => {
return allData;
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0sb0JBQ3pCLENBQUMsQ0FENEM7QUFDN0MsTUFBWSxLQUFLLFdBQU0sa0JBQWtCLENBQUMsQ0FBQTtBQVEvQixlQUFPLEdBQUcsQ0FBQyxVQUFtQjtJQUVyQywwQkFBMEI7SUFDMUIsRUFBRSxDQUFBLENBQ0UsT0FBTyxVQUFVLENBQUMsUUFBUSxJQUFJLFNBQVM7V0FDcEMsT0FBTyxVQUFVLENBQUMsZUFBZSxJQUFJLFNBQzVDLENBQUMsQ0FBQSxDQUFDO1FBQ0UsSUFBSSxpQkFBaUIsR0FBRyxFQUFFLENBQUM7UUFDM0IsaUJBQWlCLENBQUMsVUFBVSxDQUFDLFFBQVEsQ0FBQyxHQUFHLFVBQVUsQ0FBQyxlQUFlLENBQUM7UUFDcEUsVUFBVSxDQUFDLGVBQWUsR0FBRyxpQkFBaUIsQ0FBQztJQUNuRCxDQUFDO0lBQUEsQ0FBQztJQUVGLGtCQUFrQjtJQUNsQixJQUFJLFVBQWlCLENBQUM7SUFDdEIsRUFBRSxDQUFBLENBQUMsVUFBVSxDQUFDLEdBQUcsQ0FBQyxDQUFBLENBQUM7UUFDZixVQUFVLEdBQUcsT0FBTyxDQUFDLElBQ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QUFDLElBQUksQ0FBQyxDQUFDO1lBQ0osT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsd0JBQXdCLFVBQVUsQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFDO1lBQ3ZFLE1BQU0sQ0FBQyxTQUFTLENBQUM7UUFDckIsQ0FBQztJQUNMLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNKLE1BQU0sQ0FBQyxPQUFPLENBQUM7SUFDbkIsQ0FBQztBQUNMLENBQUMsQ0FBQztBQUVTLHlCQUFpQixHQUFHO0lBQzNCLE1BQU0sQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxjQUFjLENBQUMsS0FBSyxDQUFDLFVBQVUsQ0FBQyxDQUFDO0FBQ2pFLENBQUMsQ0FBQSJ9

View File

@ -12,5 +12,14 @@ describe("npmextra", function () {
});
testData.should.have.ownProperty("someKey2");
});
it("should read a config file", function () {
let testData = npmExtra.dataFor({
toolName: "testTool",
defaultSettings: { someKey2: "someValue2" },
cwd: path.join(process.cwd(), "test/")
});
testData.should.have.ownProperty("someKey2");
testData.testValue.should.equal(2);
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsTUFBTyxJQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDOUIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUVoQixNQUFPLFFBQVEsV0FBVyxlQUFlLENBQUMsQ0FBQztBQUUzQyxRQUFRLENBQUMsVUFBVSxFQUFDO0lBQ2hCLEVBQUUsQ0FBQywyQkFBMkIsRUFBQztRQUMzQixJQUFJLFFBQVEsR0FBRyxRQUFRLENBQUMsT0FBTyxDQU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7SUFDakQsQ0FBQyxDQUFDLENBQUM7SUFDSCxFQUFFLENBQUMsMkJBQTJCLEVBQUM7UUFDM0IsSUFBSSxRQUFRLEdBQUcsUUFBUSxDQUFDLE9BQU8sQ0FBQztZQUM1QixRQUFRLEVBQUMsVUFBVTtZQUNuQixlQUFlLEVBQUMsRUFBQyxRQUFRLEVBQUMsWUFBWSxFQUFDO1lBQ3ZDLEdBQUcsRUFBRSxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsRUFBQyxPQUFPLENBQUM7U0FDeEMsQ0FBQyxDQUFDO1FBQ0gsUUFBUSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLFVBQVUsQ0FBQyxDQUFDO1FBQzdDLFFBQVEsQ0FBQyxTQUFTLENBQUMsTUFBTSxDQUFDLEtBQUssQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUN2QyxDQUFDLENBQUMsQ0FBQztBQUNQLENBQUMsQ0FBQyxDQUFDIn0=

View File

@ -13,4 +13,13 @@ describe("npmextra",function(){
});
testData.should.have.ownProperty("someKey2");
});
it("should read a config file",function(){
let testData = npmExtra.dataFor({
toolName:"testTool",
defaultSettings:{someKey2:"someValue2"},
cwd: path.join(process.cwd(),"test/")
});
testData.should.have.ownProperty("someKey2");
testData.testValue.should.equal(2);
});
});

View File

@ -48,4 +48,8 @@ export let dataFor = (optionsArg:IDataFor) => {
} else {
return allData;
}
};
export let configFilePresent = ():boolean => {
return plugins.smartfile.fs.fileExistsSync(paths.configFile);
}