first working version

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

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");