Skip to content

Commit

Permalink
fix: fix exported package
Browse files Browse the repository at this point in the history
  • Loading branch information
BelfordZ committed May 16, 2019
1 parent 2dec8e7 commit 123aa9c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"test": "npm run test:lint && npm run test:unit",
"test:lint": "tslint -c tslint.json 'src/**/*.ts' --fix",
"test:unit": "jest --coverage",
"build": "tsc",
"build": "tsc && rm -rf ./build/package.json && cp -R ./build/src/* build/. && rm -rf ./build/src",
"watch:build": "tsc --watch",
"watch:test": "jest --watch"
},
Expand Down
64 changes: 33 additions & 31 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,52 @@ import { keyBy, flatten, chain } from "lodash";
import { IMethodMapping } from "./router";
import { resolve } from "path";

const version = require("../../package.json").version; // tslint:disable-line

const readDir = util.promisify(fs.readdir);
const basePath = "./src/method-handlers";

let methodMapping;
try {
methodMapping = import(`${process.cwd()}/src/method-handlers)`);
} catch (e) {
console.log("no method mapping"); // tslint:disable-line
console.log(e); // tslint:disable-line
}
const cwd = process.cwd();

program
.option("-d, --document <documentLocation>", "JSON string or a Path/Url pointing to an OpenROC document");
const init = async () => {
let methodMapping;
const { version } = await import(`../package.json`);
try {
methodMapping = await import(`${cwd}/src/method-handlers)`);
} catch (e) {
console.log("no method mapping"); // tslint:disable-line
console.log(e); // tslint:disable-line
}
program
.option("-d, --document <documentLocation>", "JSON string or a Path/Url pointing to an OpenROC document");

program
.version(version, "-v, --version")
.command("start")
.action(async (env, options) => {
const methodFilenames = await readDir(basePath);
program
.version(version, "-v, --version")
.command("start")
.action(async (env, options) => {
const methodFilenames = await readDir(basePath);

const baba = `${process.cwd()}/src/method-handlers`;
// const methodMapping = await import(baba);
const baba = `${process.cwd()}/src/method-handlers`;
// const methodMapping = await import(baba);

// const readMethodsPromises = methodFilenames.map(async (methodFilename) => {
// const methodPath = `./method-handlers/${methodFilename}`.replace(".ts", "");
// const name = methodFilename.replace(".ts", "");
// const methodHandler = await import(methodPath);
// const readMethodsPromises = methodFilenames.map(async (methodFilename) => {
// const methodPath = `./method-handlers/${methodFilename}`.replace(".ts", "");
// const name = methodFilename.replace(".ts", "");
// const methodHandler = await import(methodPath);

// return { name, fn: methodHandler.default };
// });
// return { name, fn: methodHandler.default };
// });

// const allMethodHandlers = flatten(await Promise.all(readMethodsPromises));
// const allMethodHandlers = flatten(await Promise.all(readMethodsPromises));

// const methodHandlerMap = chain(allMethodHandlers)
// .keyBy("name")
// .mapValues("fn")
// .value();
// const methodHandlerMap = chain(allMethodHandlers)
// .keyBy("name")
// .mapValues("fn")
// .value();

});
});
};

if (require.main === module) {
program.parse(process.argv);
init().then(() => program.parse(process.argv));
} else {
module.exports = program;
}

0 comments on commit 123aa9c

Please sign in to comment.