From 0907f52f534326a3fdf75144beee700c2bf6f250 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 18 Jan 2016 19:26:54 -0500 Subject: [PATCH] Expose the "version" field of package.json files at runtime. --- tools/isobuild/import-scanner.js | 1 + tools/tests/apps/modules/package.json | 2 +- tools/tests/apps/modules/tests.js | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/isobuild/import-scanner.js b/tools/isobuild/import-scanner.js index ab309a6e79..b02dc2c78e 100644 --- a/tools/isobuild/import-scanner.js +++ b/tools/isobuild/import-scanner.js @@ -449,6 +449,7 @@ export default class ImportScanner { // Output a JS module that exports just the "name" and "main" // properties defined in the package.json file. "exports.name = " + JSON.stringify(pkg.name) + ";\n" + + "exports.version = " + JSON.stringify(pkg.version) + ";\n" + "exports.main = " + JSON.stringify(pkg.main) + ";\n" ); diff --git a/tools/tests/apps/modules/package.json b/tools/tests/apps/modules/package.json index c2e750094c..805ed7711b 100644 --- a/tools/tests/apps/modules/package.json +++ b/tools/tests/apps/modules/package.json @@ -4,7 +4,7 @@ "description": "Test app exercising many aspects of the Meteor module system.", "private": true, "dependencies": { - "moment": "^2.11.1", + "moment": "2.11.1", "regenerator": "^0.8.42" }, "scripts": { diff --git a/tools/tests/apps/modules/tests.js b/tools/tests/apps/modules/tests.js index b60cdf8810..ac9d34f0d1 100644 --- a/tools/tests/apps/modules/tests.js +++ b/tools/tests/apps/modules/tests.js @@ -121,6 +121,11 @@ describe("local node_modules", () => { // Defined in packages/modules-test-package/common.js. assert.strictEqual(typeof regeneratorRuntime, "object"); }); + + it('should expose "version" field of package.json', () => { + const pkg = require("moment/package.json"); + assert.strictEqual(pkg.version, "2.11.1"); + }); }); describe("Meteor packages", () => {