From: Dan Dascalescu Date: Mon, 24 Nov 2014 03:04:58 +0000 (-0800) Subject: Fix Meteor integration and make more robust X-Git-Tag: 2.9.0~33^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9846e1bda1cdb22ef117e1bbef37c2c62b13b489;p=thirdparty%2Fmoment.git Fix Meteor integration and make more robust --- diff --git a/meteor/export.js b/meteor/export.js new file mode 100644 index 000000000..e8870ceb5 --- /dev/null +++ b/meteor/export.js @@ -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; diff --git a/meteor/package.js b/meteor/package.js index 637a85383..ab473821d 100644 --- a/meteor/package.js +++ b/meteor/package.js @@ -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']); diff --git a/meteor/publish.sh b/meteor/publish.sh old mode 100644 new mode 100755 index 90595afdd..f8892ced1 --- a/meteor/publish.sh +++ b/meteor/publish.sh @@ -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 diff --git a/meteor/runtests.sh b/meteor/runtests.sh old mode 100644 new mode 100755 index 133ad98da..1be2a1a60 --- a/meteor/runtests.sh +++ b/meteor/runtests.sh @@ -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