npmextra/ts/index.ts

27 lines
773 B
TypeScript
Raw Permalink Normal View History

2016-07-16 23:23:22 +00:00
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;
}
}