first working version
This commit is contained in:
27
ts/index.ts
Normal file
27
ts/index.ts
Normal 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
8
ts/npmextra.paths.ts
Normal 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
5
ts/npmextra.plugins.ts
Normal 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");
|
Reference in New Issue
Block a user