--- /dev/null
+// moment.js makes `moment` global on the window (or global) object, while Meteor expects a file-scoped global variable
+moment = this.moment;
+delete this.moment;
+var packageName = 'moment:moment';
+
Package.describe({
- name: 'moment:moment',
+ name: packageName,
summary: 'Moment.js: parse, validate, manipulate, and display dates - official Meteor packaging',
version: '2.8.4',
git: 'https://github.com/moment/moment.git'
Package.onUse(function (api) {
api.versionsFrom('0.9.0');
+ api.export('moment', ['client', 'server']);
api.addFiles([
- 'moment.js'
+ 'moment.js', 'meteor/export.js'
], ['client', 'server']
);
});
Package.onTest(function (api) {
- api.use('moment', ['client', 'server']);
+ api.use(packageName, ['client', 'server']);
api.use('tinytest', ['client', 'server']);
api.addFiles('meteor/test.js', ['client', 'server']);
# Publish package on Meteor's Atmosphere.js
-# Make sure Meteor is installed, per https://www.meteor.com/install
+# Make sure Meteor is installed, per https://www.meteor.com/install. The curl'ed script is totally safe; takes 2 minutes to read its source and check.
type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; }
# sanity check: make sure we're in the root directory of the checkout
-DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
+DIR=$( cd "$( dirname "$0" )" && pwd )
cd $DIR/..
# move away the package.js for Dojo
mv package.js package.dojo
cp meteor/package.js ./
-# publish and restore the Dojo package.js
-meteor publish
+# publish package, creating it if it's the first time we're publishing
+PACKAGE_NAME=$(grep -i name package.js | head -1 | cut -d "'" -f 2)
+PACKAGE_EXISTS=$(meteor search $PACKAGE_NAME 2>/dev/null | wc -l)
+
+if [ $PACKAGE_EXISTS -gt 0 ]; then
+ meteor publish
+else
+ meteor publish --create
+fi
+
+# restore the Dojo package.js
mv package.dojo package.js
type meteor >/dev/null 2>&1 || { curl https://install.meteor.com/ | sh; }
# sanity check: make sure we're in the root directory of the checkout
-DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
-cd DIR/..
+DIR=$( cd "$( dirname "$0" )" && pwd )
+cd $DIR/..
# move away the package.js for Dojo
mv package.js package.dojo
cp meteor/package.js ./
-# test and restore the Dojo package.js
+# run tests and restore the Dojo package.js even if Ctrl+C is pressed
+int_trap() {
+ echo
+ echo "Tests interrupted."
+}
+
+trap int_trap INT
+
meteor test-packages ./
+
+PACKAGE_NAME=$(grep -i name package.js | head -1 | cut -d "'" -f 2)
+rm -rf ".build.$PACKAGE_NAME"
+rm -rf ".build.local-test:$PACKAGE_NAME"
+rm versions.json
+
mv package.dojo package.js