first working version

This commit is contained in:
Philipp Kunz 2016-07-17 01:23:22 +02:00
parent 46ed6fc6df
commit 351c2aeadc
15 changed files with 139 additions and 2 deletions

2
.gitignore vendored
View File

@ -1,3 +1,3 @@
node_modules/ node_modules/
coverage/ coverage/
docs/ docs/

1
dist/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare let dataFor: (toolNameArg: string, cwdArg?: string) => any;

31
dist/index.js vendored Normal file
View File

@ -0,0 +1,31 @@
"use strict";
const plugins = require("./npmextra.plugins");
const paths = require("./npmextra.paths");
let allData;
exports.dataFor = (toolNameArg, cwdArg) => {
if (typeof allData == "undefined") {
let lookupPath;
if (cwdArg) {
lookupPath = plugins.path.join(cwdArg, "npmextra.json");
}
else {
lookupPath = paths.configFile;
}
;
allData = plugins.smartfile.fs.toObjectSync(plugins.path.join(lookupPath));
}
;
if (toolNameArg) {
if (allData[toolNameArg]) {
return allData[toolNameArg];
}
else {
plugins.beautylog.error(`There is no data for ${toolNameArg}`);
return undefined;
}
}
else {
return allData;
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0sb0JBQ3pCLENBQUMsQ0FENEM7QUFDN0MsTUFBWSxLQUFLLFdBQU0sa0JBQWtCLENBQUMsQ0FBQTtBQUMxQyxJQUFJLE9BQU8sQ0FBQztBQUVELGVBQU8sR0FBRyxDQUFDLFdBQWtCLEVBQUMsTUFBYztJQUNuRCxFQUFFLENBQUEsQ0FBQyxPQUFPLE9BQU8sSUFBSSxXQUFXLENBQUMsQ0FBQSxDQUFDO1FBQzlCLElBQUksVUFBVSxDQUFDO1FBQ2YsRUFBRSxDQUFBLENBQUMsTUFBTSxDQUFDLENBQUEsQ0FBQztZQUNQLFVBQVUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxNQUFNLEVBQUMsZUFBZSxDQUFDLENBQUM7UUFDM0QsQ0FBQztRQUFDLElBQUksQ0FBQyxDQUFDO1lBQ0osVUFBVSxHQUFHLEtBQUssQ0FBQyxVQUFVLENBQUM7UUFDbEMsQ0FBQztRQUFBLENBQUM7UUFDRixPQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsWUFBWSxDQUN2QyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxVQUFVLENBQUMsQ0FDaEMsQ0FBQztJQUNOLENBQUM7SUFBQSxDQUFDO0lBQ0YsRUFBRSxDQUFBLENBQUMsV0FBVyxDQUFDLENBQUEsQ0FBQztRQUNaLEVBQUUsQ0FBQSxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFBLENBQUM7WUFDckIsTUFBTSxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztRQUNoQyxDQUFDO1FBQUMsSUFBSSxDQUFDLENBQUM7WUFDSixPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyx3QkFBd0IsV0FBVyxFQUFFLENBQUMsQ0FBQztZQUMvRCxNQUFNLENBQUMsU0FBUyxDQUFDO1FBQ3JCLENBQUM7SUFDTCxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixNQUFNLENBQUMsT0FBTyxDQUFDO0lBQ25CLENBQUM7QUFDTCxDQUFDLENBQUEifQ==

3
dist/npmextra.paths.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
export declare let cwd: string;
export declare let packageDir: string;
export declare let configFile: string;

8
dist/npmextra.paths.js vendored Normal file
View File

@ -0,0 +1,8 @@
"use strict";
const plugins = require("./npmextra.plugins");
// directories
exports.cwd = process.cwd();
exports.packageDir = plugins.path.join(__dirname, "../");
//
exports.configFile = plugins.path.join(exports.cwd, "npmextra.json");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEucGF0aHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9ucG1leHRyYS5wYXRocy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0sb0JBQW9CLENBQUMsQ0FBQTtBQUU5QyxjQUFjO0FBQ0gsV0FBRyxHQUFHLE9BQU8sQ0FBQyxHQUFHLEVBQUUsQ0FBQztBQUNwQixrQkFBVSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBQyxLQUFLLENBQUMsQ0FBQztBQUUzRCxFQUFFO0FBQ1Msa0JBQVUsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxXQUFHLEVBQUMsZUFBZSxDQUFDLENBQUMifQ==

5
dist/npmextra.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
import "typings-global";
export import beautylog = require("beautylog");
export import path = require("path");
export import smartfile = require("smartfile");
export import q = require("q");

7
dist/npmextra.plugins.js vendored Normal file
View File

@ -0,0 +1,7 @@
"use strict";
require("typings-global");
exports.beautylog = require("beautylog");
exports.path = require("path");
exports.smartfile = require("smartfile");
exports.q = require("q");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZXh0cmEucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWV4dHJhLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQWdCLENBQUMsQ0FBQTtBQUNWLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsWUFBSSxXQUFXLE1BQU0sQ0FBQyxDQUFDO0FBQ3ZCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsU0FBQyxXQUFXLEdBQUcsQ0FBQyxDQUFDIn0=

View File

@ -15,5 +15,16 @@
"bugs": { "bugs": {
"url": "https://gitlab.com/pushrocks/npmextra/issues" "url": "https://gitlab.com/pushrocks/npmextra/issues"
}, },
"homepage": "https://gitlab.com/pushrocks/npmextra#README" "homepage": "https://gitlab.com/pushrocks/npmextra#README",
"dependencies": {
"@types/q": "0.0.27",
"beautylog": "^5.0.14",
"q": "^1.4.1",
"smartfile": "^4.0.10",
"typings-global": "^1.0.6"
},
"devDependencies": {
"should": "^9.0.2",
"typings-test": "^1.0.1"
}
} }

5
test/npmextra.json Normal file
View File

@ -0,0 +1,5 @@
{
"testTool":{
"testValue":2
}
}

2
test/test.d.ts vendored Normal file
View File

@ -0,0 +1,2 @@
import "typings-test";
import "should";

12
test/test.js Normal file
View File

@ -0,0 +1,12 @@
"use strict";
require("typings-test");
const path = require("path");
require("should");
const npmExtra = require("../dist/index");
describe("npmextra", function () {
it("should read a config file", function () {
let testData = npmExtra.dataFor("testTool", path.join(process.cwd(), "test/"));
console.log(testData);
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sY0FBYyxDQUFDLENBQUE7QUFDdEIsTUFBTyxJQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDOUIsUUFBTyxRQUFRLENBQUMsQ0FBQTtBQUVoQixNQUFPLFFBQVEsV0FBVyxlQUFlLENBQUMsQ0FBQztBQUUzQyxRQUFRLENBQUMsVUFBVSxFQUFDO0lBQ2hCLEVBQUUsQ0FBQywyQkFBMkIsRUFBQztRQUMzQixJQUFJLFFBQVEsR0FBRyxRQUFRLENBQUMsT0FBTyxDQUFDLFVBQVUsRUFBQyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxHQUFHLEVBQUUsRUFBQyxPQUFPLENBQUMsQ0FBQyxDQUFDO1FBQzdFLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxDQUFDLENBQUM7SUFDMUIsQ0FBQyxDQUFDLENBQUM7QUFDUCxDQUFDLENBQUMsQ0FBQyJ9

12
test/test.ts Normal file
View File

@ -0,0 +1,12 @@
import "typings-test";
import path = require("path");
import "should";
import npmExtra = require("../dist/index");
describe("npmextra",function(){
it("should read a config file",function(){
let testData = npmExtra.dataFor("testTool",path.join(process.cwd(),"test/"));
console.log(testData);
});
});

27
ts/index.ts Normal file
View File

@ -0,0 +1,27 @@
import * as plugins from "./npmextra.plugins"
import * as paths from "./npmextra.paths";
let allData;
export let dataFor = (toolNameArg:string,cwdArg?:string) => {
if(typeof allData == "undefined"){
let lookupPath;
if(cwdArg){
lookupPath = plugins.path.join(cwdArg,"npmextra.json");
} else {
lookupPath = paths.configFile;
};
allData = plugins.smartfile.fs.toObjectSync(
plugins.path.join(lookupPath)
);
};
if(toolNameArg){
if(allData[toolNameArg]){
return allData[toolNameArg];
} else {
plugins.beautylog.error(`There is no data for ${toolNameArg}`);
return undefined;
}
} else {
return allData;
}
}

8
ts/npmextra.paths.ts Normal file
View File

@ -0,0 +1,8 @@
import * as plugins from "./npmextra.plugins";
// directories
export let cwd = process.cwd();
export let packageDir = plugins.path.join(__dirname,"../");
//
export let configFile = plugins.path.join(cwd,"npmextra.json");

5
ts/npmextra.plugins.ts Normal file
View File

@ -0,0 +1,5 @@
import "typings-global";
export import beautylog = require("beautylog");
export import path = require("path");
export import smartfile = require("smartfile");
export import q = require("q");