From 08575d352bc2ea3b6d1729a38b569a75ce7033dc Mon Sep 17 00:00:00 2001 From: Guillaume Jenkins Date: Thu, 10 Nov 2016 12:12:57 -0800 Subject: [PATCH] pxt-microbit can now be required and exports useful information about its bundled pxt-core (#305) --- cmds/pxtrequire.ts | 4 ++++ package.json | 2 ++ 2 files changed, 6 insertions(+) create mode 100644 cmds/pxtrequire.ts diff --git a/cmds/pxtrequire.ts b/cmds/pxtrequire.ts new file mode 100644 index 00000000..26442585 --- /dev/null +++ b/cmds/pxtrequire.ts @@ -0,0 +1,4 @@ +import * as path from "path"; +export let pxtCore = require("pxt-core"); +// require.resolve() gives path to [pxt dir]/built/pxt.js, so move up twice to get pxt root dir +export let pxtCoreDir = path.resolve(require.resolve("pxt-core"), "..", ".."); diff --git a/package.json b/package.json index 2bbcc8ba..fff387f8 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,8 @@ "docs/*/*.md", "docs/*/*/*.md" ], + "main": "built/pxtrequire.js", + "typings": "built/pxtrequire.d.ts", "devDependencies": { "typescript": "^1.8.7" },