]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fix Meteor integration and make more robust
authorDan Dascalescu <ddascalescu+github@gmail.com>
Mon, 24 Nov 2014 03:04:58 +0000 (19:04 -0800)
committerDan Dascalescu <ddascalescu+github@gmail.com>
Mon, 24 Nov 2014 11:45:30 +0000 (03:45 -0800)
meteor/export.js [new file with mode: 0644]
meteor/package.js
meteor/publish.sh [changed mode: 0644->0755]
meteor/runtests.sh [changed mode: 0644->0755]

diff --git a/meteor/export.js b/meteor/export.js
new file mode 100644 (file)
index 0000000..e8870ce
--- /dev/null
@@ -0,0 +1,3 @@
+// 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;
index 637a85383741ca30c06206f417b3a64376851dc0..ab473821d930b66f217171113a686f942d97154a 100644 (file)
@@ -1,5 +1,7 @@
+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'
@@ -7,14 +9,15 @@ Package.describe({
 
 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']);
old mode 100644 (file)
new mode 100755 (executable)
index 90595af..f8892ce
@@ -1,16 +1,25 @@
 # 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
old mode 100644 (file)
new mode 100755 (executable)
index 133ad98..1be2a1a
@@ -4,13 +4,26 @@
 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