Commit Graph

3 Commits

Author SHA1 Message Date
David Glasser
89c22bf634 Fix crash on duplicate files in a package
Adding the same file twice in the same package is now an
error. Previously, this could either lead to the file being included
multiple times (eg, JS), or to a build time crash (eg, client-side
assets).
2015-03-31 10:52:43 -04:00
David Glasser
a17fcf253c Fix useMyCaller
Before:

   While reading package from
   `/private/tmp/meteor-duplicate-path-error/packages/dupe`:

   /Users/glasser/.meteor/packages/meteor-tool/.1.0.45.1y6cwq8++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/package-api.js:22:5:
   Invalid 'where' argument: '[object Object]'
   at Array.forEach (native)
   at Function._.each._.forEach
   (/Users/glasser/.meteor/packages/meteor-tool/.1.0.45.1y6cwq8++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
   at toArchArray
   (/Users/glasser/.meteor/packages/meteor-tool/.1.0.45.1y6cwq8++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/package-api.js:22:5)
   at PackageAPI._.extend.addFiles
   (/Users/glasser/.meteor/packages/meteor-tool/.1.0.45.1y6cwq8++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/tools/package-api.js:287:12)
   at package.js:2:7

After:

   While reading package from
   `/private/tmp/meteor-duplicate-path-error/packages/dupe`:
   package.js:2:7: Invalid 'where' argument: '[object Object]'

The major problem here was that numeric useMyCaller never quite worked,
since useMyCaller was only used to calculate the file/line/etc for the
error, and not to convince formatMessages to not print the rest of the
stack.

The other issue is that `_.each` adds two levels of stack over just
using a `for` loop, whereas 8bcbd6534 only added 1 to the useMyCaller
argument.
2015-03-31 10:52:42 -04:00
Ben Newman
af50b4cc5b Define a class called PackageAPI and put it in its own file.
Summary:
The methods of the ad-hoc `api` object needed access to very few variables
from the surrounding lexical environment, and those few variables
(`sources`, `exports`, `uses`, `implies`) are better regarded as member
variables of the `PackageAPI` class.

Test Plan: `meteor test-packages`

Reviewers: Slava, dgreensp, glasser

Reviewed By: glasser

Differential Revision: https://phabricator.meteor.io/D30
2015-03-03 14:27:04 -05:00